Solved

common method for database connection?

Posted on 2001-06-12
2
158 Views
Last Modified: 2010-05-02
I wrote the following code in my MDIForm load method.....This is my first loading form name.So i wrote
the common coneection here.
But when i run this application ..i got compilation error
like "Invalid attribute in sub or function"..
Can u help me from this please...
rgds,
rajani
Public Sub MDIForm_Load()
    Dim sConnect As String
    Public dfwConn As ADODB.Connection
    Dim cmd As ADODB.Command
     'set strings
        sConnect = "Provider=MSDASQL.1;Connect Timeout=15;Extended Properties='DSN=ACR;DBQ=c:\windows\desktop\ACRData.mdb;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;';Locale Identifier=3081"
        ' open connection
        Set dfwConn = New Connection
        dfwConn.Open sConnect
        Set cmd = New Command
        cmd.ActiveConnection = dfwConn
        cmd.CommandType = adCmdStoredProc
     
End Sub
0
Comment
Question by:rajani50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
dtomyn earned 20 total points
ID: 6184214
Move the line "Public dfwConn As ADODB.Connection" out of the sub procedure (put it in the General Declarations section).  That is, a procedure can not have declared within it a public variable.
0
 

Author Comment

by:rajani50
ID: 6184325
thanks for ur reply
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MsgBox 4 71
VB6 - Scroll Mouse wheel on Picturebox 13 94
Sub or Function is not defined 6 53
Help with Classic ASP - Parameterizing Query 16 16
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

761 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question