using System;
using System.Data.SqlClient;
?
namespace LocalDBExample
{
class Program
{
static void Main(string[] args)
{
string connectionString=”Server=(localdb)\MSSQLLocalDB;Database=YourDatabaseName;User Id=sa;Password=YourPassword;”;
?
using (SqlConnection connection=new SqlConnection(connectionString))
{
connection.Open();
Console.WriteLine(“Connected to the database successfully!”);
?
// 在此处执行您的数据库操作
?
connection.Close();
}
}
}
}
using System.Data.SqlClient;
?
namespace LocalDBExample
{
class Program
{
static void Main(string[] args)
{
string connectionString=”Server=(localdb)\MSSQLLocalDB;Database=YourDatabaseName;User Id=sa;Password=YourPassword;”;
?
using (SqlConnection connection=new SqlConnection(connectionString))
{
connection.Open();
Console.WriteLine(“Connected to the database successfully!”);
?
// 在此处执行您的数据库操作
?
connection.Close();
}
}
}
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。