Someone can tell me where i m doing mistake in order to show Autogenerate Id everytime with increasing of one.
string conn = @"Data Source=FARHAD-PC\SQLEXPRESS;Initial Catalog=shop;Integrated Security=True";
myconnection = new SqlConnection(conn);
myconnection.Open();
string query_Id = "select * from tblEmployee";
mydataadapter = new SqlDataAdapter(query_Id, myconnection);
mydataset = new DataSet();
mydataadapter.Fill(mydataset);
try
{
int index = (int) mydataset.Tables[0].Rows.Count - 1;
iRegNo = (int)mydataset.Tables[0].Rows[index].ItemArray[1] + 1;
txtID.Text = iRegNo.ToString();
}
catch (IndexOutOfRangeException iore)
{
txtID.Text = "1";
}
everytime error showing is specified cast is not valid.
:(
whats problem?
Regards...