protected void Page_Load(object sender, EventArgs e) { string path = "Data Source=192.168.1.14;Initial Catalog=nazer;User ID=sa;Password=admin*123"; SqlConnection con = new SqlConnection(path); con.Open(); string query = "select MAX(id) from tbl_samp1"; SqlCommand cmd = new SqlCommand(query, con); SqlDataReader dre=cmd.ExecuteReader(); while (dre.Read()) { int values = (int)dre["id"]; //what error in this line? please... TextBox1.Text = values.ToString(); } con.Close(); }
int values = dre.GetInt32(id);
NULL
dre["id"]
select MAX(id) as id from tbl_samp1
int values = int.Parse(dre["id"].ToString());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)