SqlConnection connection = new SqlConnection("connectionString"); SqlCommand command = new SqlCommand("CREATE TABLE tableName (columnOne datatype, columnTwo datatype, columnThree datatype)", connection); connection.Open(); command.ExecuteNonQuery(); connection.Close();
SqlConnection connection = new SqlConnection("connectionString"); SqlCommand command = new SqlCommand("INSERT INTO tableName (columnOne, columnTwo, columnThree) VALUES (@valueOne, @valueTwo, @valueThree)", connection); command.Parameters.AddWithValue("@valueOne", "dataOne"); command.Parameters.AddWithValue("@valueTwo", "dataTwo"); command.Parameters.AddWithValue("@valueThree", "dataThree"); connection.Open(); command.ExecuteNonQuery(); connection.Close();The package library used in these examples is System.Data.SqlClient, which is a part of the .NET Framework and provides a way to work with SQL Server databases using C#.