2012-10-23 74 views
1

我面临的问题OLEDB连接问题

“[DBNETLIB] [ConnectionOpen(无效的实例())。]无效的连接。”

while using OLDDBConnection。下面的代码我使用

Dim objConn As OleDbConnection = New OleDbConnection("Provider=sqloledb;Data Source=IPADDRESS;Initial Catalog=EMS;User Id=****;Password=****;") 
Dim objDS As DataSet = New DataSet() 
Dim objCmdSelect As OleDbCommand = New OleDbCommand("select top 10 from EL_SERVER", objConn) 
Dim objAdapter1 As OleDbDataAdapter = New OleDbDataAdapter() 
objAdapter1.SelectCommand = objCmdSelect 
objAdapter1.Fill(objDS) 
+0

可能重复http://stackoverflow.com/questions/4156301/invalid-instance-when-using-adodb-recordset – PatFromCanada

回答

1
You will need to check if you are using correct Data Source name in your connection string. If you are using localhost then try to use IP address of server. If you have SQL server with the Instance then use instance name with the server Ip in your connection string. 


OR 

please remove the star symbol and type your user name and password on there.. 
    example: 
    Dim objConn As OleDbConnection = New OleDbConnection("Provider=sqloledb;Data Source=IPADDRESS;Initial Catalog=EMS;User Id=abc;Password=abc;")