错误连接SQL [英] error to connect sql

查看:126
本文介绍了错误连接SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 在连接到sql创建数据库或向数据库添加数据时,如何解决此错误:
我用dotnet安装sqlexpress


与网络相关的实例特定的错误
尽管

建立与SQL Server的连接.未找到服务器 ,或者是 not 无障碍.验证实例名称是否正确,并且 SQL Server已配置为允许远程连接. (提供者:命名管道提供者,错误: 40 -可能>无法打开与SQL Server的连接)



!!!!!!!!我的sql server工作正常
因为当我将sqldatasource拖到我的页面并与它关联一个数据网格
我的数据库工作良好

我使用此代码创建db

 {
  字符串 strsql,strcon;
        strcon = " ;
        SqlConnection con =  SqlConnection(strcon);
        SqlCommand cmdclasf;
        strsql = " ;
        con.Open();
        cmdclasf =  SqlCommand(strsql,con);
         int  count = cmdclasf.ExecuteNonQuery();
        con.Close();
        如果(计数==  0 )
            Label1.Text = " ;
        其他
            Label1.Text = " ;
} 

解决方案

朋友们,

正确检查您的连接字符串....

它来自于您的连接字符串...

如果数据源来自网络,则检查网络服务器是否正在运行.


请参阅以下链接:

^ ]

建立连接时发生与网络相关或与实例有关的错误到SQL Server.找不到服务器或无法访问服务器. [ ^ ]

http://stackoverflow.com/Questions/1391503/a-network-related-or-instance-specific-error-while-建立conne时发生的错误 [ ^ ]


hi how can i solve this error in connect to sql to create a database or add data to database:
i install sqlexpress with dotnet


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)



!!!!!!!!my sql server is good work
because when i and drag a sqldatasource to my page and related a datagrid with it
my database work good

i used this code for create db

{
  string strsql, strcon;
        strcon = "Data Source=(1-pc);Initial Catalog=neww.mdf;Integrated Security=true";
        SqlConnection con = new SqlConnection(strcon);
        SqlCommand cmdclasf;
        strsql = "create database product";
        con.Open();
        cmdclasf = new SqlCommand(strsql, con);
        int count = cmdclasf.ExecuteNonQuery();
        con.Close();
        if (count == 0)
            Label1.Text = "not create";
        else
            Label1.Text = "created";
}

解决方案

Hi friends,

Check ur connection string properly....

it is from ur connection string...

if the data source is from network, then check the network server is running or not.


Refer these links:

http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/[^]

http://chanmingman.wordpress.com/2011/07/11/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-s/[^]


Check Your connection string .

see these links

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.[^]

http://stackoverflow.com/questions/1391503/a-network-related-or-instance-specific-error-occurred-while-establishing-a-conne[^]


这篇关于错误连接SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆