我装了visual studio里带着的sql sever 2005。用以下代码创建数据库 //1、建立连接
SqlConnection connection = new SqlConnection("data source=(local);initial catalog=master;user id= test;password= test");
//2、建立数据库
SqlCommand command = connection.CreateCommand();
command.CommandText = "CREATE DATABASE (local)";
try
{
connection.Open();
command.ExecuteNonQuery();
}
catch
{
Console.WriteLine("创建数据库失败");
Console.ReadKey();
}
finally
{
command.Dispose();
connection.Dispose();
}执行到connection.Open();时就错了:
在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)我应该怎么做?
SqlConnection connection = new SqlConnection("data source=(local);initial catalog=master;user id= test;password= test");
//2、建立数据库
SqlCommand command = connection.CreateCommand();
command.CommandText = "CREATE DATABASE (local)";
try
{
connection.Open();
command.ExecuteNonQuery();
}
catch
{
Console.WriteLine("创建数据库失败");
Console.ReadKey();
}
finally
{
command.Dispose();
connection.Dispose();
}执行到connection.Open();时就错了:
在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)我应该怎么做?
data source=(local)\sqlexpress; ...
你需要单独安装一个SQLSERVER
你是默认装的VS自带的SQL2005???
那只是个SQL管理而已,没啥用处.
要先装SQL,在装VS...