ADO增删查改
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ADO
{
class Program
{
//1、连接字符串
private static string connectionString = "server=localhost;database=MyScool;uid=sa;pwd=123";
static void Main(string[] args)
{
#region 创建数据库的连接
//2、创建数据库的连接
//①
//SqlConnection conn = new SqlConnection(connectionString);
// //②
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connectionString;
3、打开数据库的连接
//conn.Open();
//Console.WriteLine(conn);
4、关闭当前数据库连接
//conn.Close();
5、销毁当前数据库连接
//conn.Dispose();
//Console.WriteLine(conn);
//Console.ReadKey();
#endregion
#region 执行SQL的 聚合函数
1 创建数据库连接对象
//SqlConnection conn = new SqlConnection(connectionString);
2 打开数据库的连接
//conn.Open();
3 创建command对象
//SqlCommand command = new SqlCommand("select COUNT(*) from t_Student", conn);