hi,
in my windows forms application project, i have placed one Label control, and one textbox control and a button.
For increment the number which was in Label control. I have set the Label Properties as follows:
Label1--> Properties---> text -- 1
Enabled---> false so that when form load, first time label will show id as 1 , from then it will increment each time by 1.
If i click on button[Next] then Id(1) will be saved in database table and Label will display id as 2 , if i click Button[Next] again then id will saved and show id as 3 , like that it will increments each time by 1. For that i wrote the code as follows:
Button1_Click()
{
SqlConnection con = new SqlConnection("user id=sa;password=123;database=empdetails");
con.Open();
SqlCommand cmd = new SqlCommand("select max(id) as id from employee", con);
cmd.CommandType = CommandType.Text;
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
if (dr["id"].ToString() != "")
{
temp = int.Parse(dr["id"].ToString()) + 1;
}
else
{
temp = 1;
}
label24.Text = temp.ToString();
dr.Close();
con.Close();
}
this is working but id is incrementing upto 10 only , after that it is not incrementing to 11,12,13...
Please solve this , i want the id upto 1000 employees
I have created the table with values as id (char) , table name as employee in empdetails database, i wrote the code for saving the id in the table.
But id is not incrementing after 10 , please give the solution for incrementing after 10