SqlCommand.ExecuteScalar()
return the data of first row,first column.
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);
int values = Convert.ToInt32(cmd.ExecuteScalar());
TextBox1.Text = values .ToString();