Solved

common method for database connection?

Posted on 2001-06-12
2
151 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
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now