This C# program demonstrates how to create an SQL table for Microsoft SQL in C#.
using System;
using System.Data.SqlClient;
namespace CreateTable {
class Program {
static void Main(string[] args) {
Console.WriteLine(CreateTable());
}
public static int CreateTable() {
// The using block ensures that the connection is closed when it exits this block.
using (SqlConnection qConnection = new SqlConnection(
@"Server=localhost\SQLEXPRESS01;Database=catholic;Trusted_Connection=True;")) {
SqlCommand qCommand = qConnection.CreateCommand();
qCommand.CommandText =
"CREATE TABLE apostles(name varchar(30), symbol varchar(20));";
qCommand.Connection.Open();
return qCommand.ExecuteNonQuery();
}
}
}
}
-1 Press any key to continue . . .
© 20072024 XoaX.net LLC. All rights reserved.