Where to put the SELECT SCOPE_IDENTITY()
statement if I want to get the last inserted identity, I put it inside other insert into query but I get nothing..
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
connection.Open();
string insACmd = "insert into admin (userName, password) values (@userName, @password) SELECT SCOPE_IDENTITY();";
SqlCommand insertAdmin = new SqlCommand(insACmd, connection);
insertAdmin.Parameters.AddWithValue("@userName", TextBox1.Text);
insertAdmin.Parameters.AddWithValue("@password", TextBox2.Text);
string insertedID = insertAdmin.ExecuteScalar().ToString();
connection.Close();
Thanks.