Last active
July 19, 2020 14:06
-
-
Save mikependon/df481f9d88c04d90272698891eb357bf to your computer and use it in GitHub Desktop.
ADO_Insert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var connection = new SqlConnection(connectionString)) | |
{ | |
connection.Open(); | |
using (var command = connection.CreateCommand()) | |
{ | |
command.CommandText = "INSERT INTO [dbo].[Customer](Name, ..., CreatedDateUtc) VALUES (@Name, ..., @CreatedDateUtc); SELECT SCOPE_IDENTITY();"; | |
command.Parameters.AddWithValue("@Name", customer.Name); | |
... | |
command.Parameters.AddWithValue("@CreatedDateUtc", customer.CreatedDateUtc); | |
return (int)command.ExecuteScalar(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment