void autogenerated()
{
con.Open();
string dp = DropDownList2.SelectedValue;
dp = dp.ToLower();
SqlCommand com = new SqlCommand("select count(*) from " + dp, con);
count = Convert.ToInt16(com.ExecuteScalar()) + 1;
string dt = TextBox6.Text;
string st = dt.Substring(3, 2);
string st1 = dt.Substring(8, 2);
string cu = DropDownList2.Text.Substring(0, 2);
Session["e"] = "ST" + st + st1 + cu + count.ToString();
con.Close();
TextBox1.Text = Session["e"].ToString();
}
the above code is running properly but the problem is it cannot able to count the total no of records from the table.here the tables name are taken from dropdown list. but data are submitting in proper table.here is the generated ids ST1014Au2, ST0416Au2, ST0113Au2, ST0816Au2.the problem is in the last character , it's only generating '2'.i want to count the records from different table which ever will be selected and the last no must be the (total no of record+1).the result i want ST1014Au1, ST0416Au2, ST0113Au3...if i would write the table namr like this SqlCommand com = new SqlCommand("select count(*) from auto1" , con); then it's counting properly.but in this way i can take only one fix table name!!!!!
please reply