Parameterized SQL statement: Difference between revisions

m
Use type inference. Wrap managed objects SqlConnection and SqlCommand in using statements to ensure they are closed on exiting method scope as per Microsoft docs https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection
m (→‎{{header|Phix}}: syntax coloured, included the nicer pretty print routines and named parameters)
m (Use type inference. Wrap managed objects SqlConnection and SqlCommand in using statements to ensure they are closed on exiting method scope as per Microsoft docs https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection)
Line 258:
static void Main(string[] args)
{
SqlConnectionusing var tConn = new SqlConnection("ConnectionString");
 
SqlCommandusing var tCommand = new SqlCommandtConn.CreateCommand();
tCommand.Connection = tConn;
tCommand.CommandText = "UPDATE players SET name = @name, score = @score, active = @active WHERE jerseyNum = @jerseyNum";