Friday, April 29, 2011

string query = "Insert Into tests (tests) Values (@tests);" +
"Select @@Identity";
using (SqlConnection conn = new SqlConnection(connStr))
{
using (SqlCommand cmd = new SqlCommand(query, conn))
{

cmd.Parameters.AddWithValue("@tests", "tests");
conn.Open();
//cmd.ExecuteScalar();
int Idd;
Idd = Convert.ToInt32(cmd.ExecuteScalar());
lblMessage.Text = "ggggggggg" + Idd;
}
}

0 Comments:

Post a Comment