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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADOBD connection to ODBC data source

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I am able to open the connection but I get an error trying to open the recordset.
I want to just pass a SQL string and set a recordset to it.

here is my code

Dim Conn2 As ADODB.Connection, rst As Recordset, SQLcode2 As String
Set Conn2 = New ADODB.Connection

Conn2.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=COMPX;"
SQLcode2 = "Select SALES_ORDER, CUSTOMER FROM none_SO_MASTER_HDR Where SALES_ORDER = '" & Ordernum & "';"

' Open Employee table.
Set rst = New ADODB.Recordset
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open "none_SO_MASTER_HDR", Conn2, , , adCmdTable '
< Error here
Run time error -2147217887 (80040e21)
ODBC driver does not support the requested properties


TIA DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
the adCmdTable parameter should be adCmdText to open a recordset based on a querey. The first parameter is your querey string, followed by the connection, type of recordset, and type of locking. The statement below will open the recordset based on your querey and the resulting recordset will be scrollable and updatable and will hold locks on any records included in the recordset.
Code:
rs.Open SQLcode2, Conn2, adOpenKeyset, adLockPessimistic, adCmdText
This will open a firehose cursor (scroll forward only, read only, won't hold locks on the data. This is the fastest and most concurrency friendly type of recordset to work with but you can't update with it.
Code:
   rs.Open SQLCode2, Conn2, adOpenForwardOnly, adLockReadOnly, adCmdText
Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top