Posted on: 10/11/2013 4:36:43 AM | Views : 806

hello guys,
I have 3 tables in my project, I want to take last id for 3 tables each one individually in one page,
i get last id for 1 table by code:
protected void Page_Load(object sender, EventArgs e) { string db = ""; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); con.Open(); SqlCommand cmd = new SqlCommand(); //SqlCommand cmd1 = new SqlCommand(); cmd.CommandText = "SELECT MAX(id) FROM info";// here you can put your own query ////// // cmd.CommandText = "SELECT MAX(id) FROM t1"; cmd.Connection = con; SqlDataReader dr; dr = cmd.ExecuteReader(); //dr = cmd1.ExecuteReader(); while (dr.Read()) { Label1.Text = dr[0].ToString(); //Label2.Text = dr[0].ToString(); } ...

Go to the complete details ...