Hi,
am create a Login Page . then i want to check roleid in the logintable.
my code is..
MySqlCommand cmd = new MySqlCommand("select * from login where empcode =@empcode and password=@password ", cn);
cmd.Parameters.AddWithValue("@empcode", txtempcode.Text);
cmd.Parameters.AddWithValue("@password", txtpass.Text);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Response.Redirect("Home.aspx");
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "");
}
}
roleid is 1,2,3
using this roleid only i want to login....
Login page
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Riddhi ValechaRank #794 · 2.9K reputationPosted Feb 10, 2015, 10:06 PM EST
1. Use TRIM() Function. It will remove all spaces.
2. You will have the results in your datatable. Access them using DataRow.
Eg -
foreach ( Datarow dr in dt.Rows)
{
string s = dr["ColumnName"].ToString().Trim();
}
--
Here you will get the values of all cells of a row...