SqlCommand cmd = new SqlCommand("INSERT INTO Users (" + "LoginName," + "FirstName," + "LastName," + "Password," + "Email," + "DOB," + "Sex" + ") VALUES (" + "@Email," + "@FirstName," + "@LastName," + "@Password," + "@Email," + "@DOB," + "@Sex)" + " Select Scope_Identity();",conn);
Here is how you would execute the query:
int UserId = (int)cmd.ExecuteScalar();
Most of the time you will need to use the Scope_Identity() when you have to deal with foreign key constraints, that's why a Users table is a good example.
Thanks for sharing such an Amazing information, I Couldn't leave without reading your blog. I have read another good blog, I think you have read it too. click here Trend Micro bellen
ReplyDeleteAivivu đại lý vé máy bay, tham khảo
ReplyDeleteVé máy bay đi Mỹ
vé máy bay eva từ mỹ về việt nam
từ canada về việt nam quá cảnh ở đâu
bay nhật bản việt nam
dat ve may bay tu han quoc ve viet nam
Vé máy bay từ Đài Loan về Việt Nam
chuyen bay chuyen gia