SQL Table Valued Function

spinkung

Registered User.
Local time
Today, 00:31
Joined
Dec 4, 2006
Messages
267
Hi


i'm trying to connect to a table valued function on sql (2005) but keep getting the following error:

argument are of the wrong type, are out of acceptable range, or in conflict with one another

here's the code


Code:
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset

Set cnn = New ADODB.Connection
cnn.ConnectionString = "DSN=mydsn;UID=myuser;PWD=mypw;"
cnn.Open

Dim myValue As String
myValue = "123456"

rst.Open "select * from [dbo].[tvf_ASN_bodyShop_header] ('" & myValue & "')", cnn.Connection, adOpenKeyset, adLockReadOnly

is there another way i should be doing this?

Thanks
 
cnn is the connect object. Not cnn.connection
 
thanks


so that now leads to the following error...

Object variable or with variable not set

Code:
rst.Open "select * from [dbo].[tvf_ASN_bodyShop_header] ('" & myAsn & "')", cnn, adOpenKeyset, adLockReadOnly
 
resolved:

this is the way to use it...

Code:
Set rst = cnn.Execute("select * from [dbo].[tvf_ASN_bodyShop_header] ('" & myAsn & "')")
 
That is one way.

The other problem with your first attempt is that you didn't instantiate the recordset first.

Set rs = New ADODB.Recordset
rs.Open blah
 

Users who are viewing this thread

Back
Top Bottom