Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Dec 8, 1999

DSN-Less with ADO

Question:
When I try to implement the code that is in MSDN, I receive Run-time error '446' Object doesn't support named arguments.
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Const ConnectString = "uid=myname;pwd=mypw;driver={SQL Server};" & _
 "server=myserver;database=pubs;dsn=''"

Private Sub Form_Load()
   With cn
      ' Establish DSN-less connection
      .ConnectString = ConnectString
      .ConnectionTimeout = 10
      .Open
   End With
 
It fails on the ConnectString. How can I correct this problem?

Answer:
You can't create the objects using the New keyword outside of a subroutine. Either move the variable declarations (cn and rs) within the Form_Load event handler, or use this code:

Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date