OLEDB连接问题

时间:2012-10-23 19:44:26

标签: sql vb.net

我正面临问题

  

“[DBNETLIB] [ConnectionOpen(Invalid Instance())。]连接无效。”

使用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)

1 个答案:

答案 0 :(得分: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;")