Inserts (create) a new table : SqlCommand Update « ADO.Net « C# / CSharp Tutorial






using System;
using System.Data.SqlClient;

public class UpdateRecord
{
    public static void Main() 
    {
        string connectionString = "Data Source=localhost;" +
                      "Initial Catalog=Northwind;Integrated Security=SSPI";
        string SQL = "CREATE TABLE Users (UserName nvarchar(20), Password nvarchar(20) )";

        SqlConnection con = new SqlConnection(connectionString);
        SqlCommand cmd = new SqlCommand(SQL, con);

        con.Open();
        int rowsAffected = cmd.ExecuteNonQuery();
        con.Close();

        Console.WriteLine(rowsAffected);
    }
}








32.22.SqlCommand Update
32.22.1.Updating Data Using Sql Statements
32.22.2.Execute NonQuery Example: update
32.22.3.Inserts (create) a new table