2012-10-23 75 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;")