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....
Loading
Riddhi ValechaPosted Feb 11, 2015, 3:06 AM
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...