I got an error trying to retrieve data into a recordset. I use the following code:
Dim ServerName As ADODB.Connection
Set ServerName = New ADODB.Connection
ServerName.ConnectionString = "Provider=SQLOLEDB.1;Data Source=any server;Initial Catalog=any database;User Id=any user id;Password=;"
ServerName.Open
Dim RS As New ADODB.Recordset
RS.Open "any_table", ServerName, adOpenStatic, adLockReadOnly, adCmdTableDirect
I got the run-time error -2147217865 (80040e37): Invalid object name.
If I replace "any_table" with "Select * from any_table", then I get the error: Table does not exist.
Does anyone know how to solve this? Thanks.
Dim ServerName As ADODB.Connection
Set ServerName = New ADODB.Connection
ServerName.ConnectionString = "Provider=SQLOLEDB.1;Data Source=any server;Initial Catalog=any database;User Id=any user id;Password=;"
ServerName.Open
Dim RS As New ADODB.Recordset
RS.Open "any_table", ServerName, adOpenStatic, adLockReadOnly, adCmdTableDirect
I got the run-time error -2147217865 (80040e37): Invalid object name.
If I replace "any_table" with "Select * from any_table", then I get the error: Table does not exist.
Does anyone know how to solve this? Thanks.