C#连接SQL server2008 出现错误

Anetwork-relatedorinstance-specificerroroccurredwhileestablishingaconnectiontoSQLServ... A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
using System;
using System.Data.SqlClient;
public class a
{
public static void Main(string[] args)
{
string source = "server = (loacal);" +
"integrated security = SSPI;" +
"database = nihao";
string select = "update buhao" +
"set age = 10" +
"where name= 'zhang'";
SqlConnection conn = new SqlConnection(source);
conn.Open();
SqlCommand cmd = new SqlCommand(select, conn);
int rowsReturned = cmd.ExecuteNonQuery();
Console.WriteLine("{0} rows affect!");
conn.Close();
Console.WriteLine();
}
}
这是我编写的代码,刚刚才接触C#有关数据的操作
展开
 我来答
百度网友b173602
2011-08-07 · TA获得超过1680个赞
知道小有建树答主
回答量:1466
采纳率:0%
帮助的人:829万
展开全部
关注中
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式