We help IT Professionals succeed at work.

MySQL / VBMYSQLDirect.dll / Trying to make an easier connection

thaburner
thaburner asked
on
811 Views
Last Modified: 2012-05-05
What im trying to do is make it so i dont have to type all the text in the Getdata and close data fields to get a simple connection. Im trying to make it simple lol, is this possilbe this way to do it globally. At the moment when i try to do it i get a Runtime 91 , Object variable or with block variable not set for the Getdata line in the form.

'=== FORM
    sdb.GetData "SELECT * FROM Misc;" 'Open connection
    gdRS.MoveFirst
    txtEmployeeID.Text = gdRS.Fields("NextEmployeeID")
    sdb.CloseData 'Close connection


'===MODULE (MainMOD)
Global sdb As MySQL_DB
Global gdRS As MYSQL_RS
Global gdConn As MYSQL_CONNECTION

'===CLASS (MYSQL_DB)

Public Function GetData(ByVal SQL_SYNTAX As String)
On Error GoTo ErrHandler

Set gdRS = New MYSQL_RS
Set gdConn = New MYSQL_CONNECTION

gdConn.OpenConnection strSvrAddress, strUsername, strPassword, strSvrSchema, strSvrPort
gdRS.OpenRs SQL_SYNTAX, gdConn


ErrHandler:
    If Err.Number <> 0 Then
    EBox Err.Number, Err.Description, SQL, ""
    End If
End Function

Public Function CloseData()
On Error GoTo ErrHandler

    gdRS.CloseRecordset
    gdConn.CloseConnection
    Set gdRS = Nothing
    Set gdConn = Nothing
   
ErrHandler:
    If Err.Number <> 0 Then
    EBox Err.Number, Err.Description, VBCode, ""
    End If
End Function
Comment
Watch Question

Senior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thx that did the trick now may i ask what differnce it makes when you must NEW by it?
Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016

Commented:
NEW creates a new instance. That means that everything inside the object is now accessible.

Without the NEW, your instance is not created. It is only a pointer to nothing and it cannot be used.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.