Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Recordset Error

Status
Not open for further replies.

mcm103

Technical User
Sep 28, 2001
20
0
0
US
I am trying to customize a Microsoft Outlook Form. It uses VBScript to handle the customization. I am trying to ADO to connect to a SQL Server Database. I am connecting fine the problem is with the RecordSet. My Code is as follows:

Set conn = Item.Application.CreateObject("ADODB.Connection")
Set rs = Item.Application.CreateObject("ADODB.Recordset")

conn.open "Connection String; User ID; Password"

Query = "Select * From TableName"

Set rs = conn.Execute(query)

The code is generating a error on the last line.

The error states that the Tablename is an invalid object.

What am I missing?



 
I'm not sure if the syntax is the same in VBScript as it is in regular VB, but this is the way you would do the last line in VB:

rs.Open Query, conn, adOpenForwardOnly, adLockReadOnly, adCmdText

Actually, if you are simply opening a table, you don't even need the "Query" variable. A simple statement to open a table with a cursor that allows you to move forward and backward within the table and allows editing would be:

rs.Open "TableName", conn, adOpenStatic, adLockOptimistic, adCmdTable

Hope that is of some help.
 
I tried that method as well and got the same error.
 
What is actually the name of your table? For instance does it contain spaces or illegal characters/ Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
tablenames could be Hardware1 and Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top