C# 操作SQL Server数据库, 数据库连接测试
using System; using System.Data.SqlClient; namespace SqlServerDemo { class Program { static void Main(string[] args) { string connectionString = "Data Source=127.0.0.1,1433;Initial Catalog=TestDB;uid=sa;pwd=123456"; using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); } Console.WriteLine("数据库连接成功."); Console.Read(); } } }