Results 1 to 11 of 11

Thread: [RESOLVED] Error Help Please

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Resolved [RESOLVED] Error Help Please

    Im coming across this error you can see it on the screenshot can anyone help me please.?

    This is the connection code.

    Code Code:
    1. Option Explicit
    2.  
    3. Public con As New ADODB.Connection
    4. Public rs As New ADODB.Recordset
    5. Public days As Integer
    6. Public Username As String
    7.  
    8. Public Sub Main()
    9.  
    10.     Set con = New ADODB.Connection
    11.                                                                    
    12.     con.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=76.76.18.105;DATABASE=webspace_money;USER=webspace_money;PASSWORD=d82f1fc;"
    13.    
    14.     frmLogin.Show
    15.    
    16. End Sub
    Attached Images Attached Images  
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  2. #2
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: Error Help Please

    Are you able to connect to this database from your ODBC Data Source Administrator?
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: Error Help Please

    I ament doing it through the PC's mysql server it's going through my websites mysql?
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Error Help Please

    Do you have one of the "Microsoft ActiveX Data Objects 2.x Library" selected in the project references?

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Error Help Please

    Thread moved to Database Development forum (the "VB6" forum is meant for questions which don't fit in more specific forums)

    Quote Originally Posted by Jamie_Garland
    I ament doing it through the PC's mysql server it's going through my websites mysql?
    I've got no idea what that was supposed to mean, or how it was supposed to answer abhijit's question - and the best thing you can do at this stage is answer it.
    Quote Originally Posted by MarkT
    Do you have one of the "Microsoft ActiveX Data Objects 2.x Library" selected in the project references?
    He must have, otherwise a different error would occur on the Dim lines.

    This particular error occurs at the stage where ADO is attempting to communicate with the database driver, which means that the interaction between VB and ADO is fine.

  6. #6
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Error Help Please

    Quote Originally Posted by si_the_geek View Post
    He must have, otherwise a different error would occur on the Dim lines.
    Good point.

    I would start by finding a connection string that works. Probably the easiest way to do this is through a UDL file.

    Create a new Text file and change the extenstion to .udl. Then double click the UDL to open it. From the Provider tab select the driver and then go on to the connection tab. After adding all the info, test the connection. If it works, click the OK button. Now open the UDL file using Notepad. The connection string will be the last line in the file.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: Error Help Please

    This is the login code and it highlights the con.open.

    I dont use the pc for it i use my mysql on my webserver to connect too.

    code Code:
    1. Set rs = New ADODB.Recordset
    2.     If Trim(txtUsername.Text) = "" Then Exit Sub
    3.     If con.State = 0 Then con.Open
    4.    
    5.     rs.Open "select password,usertype from Users where username='" & txtUsername.Text & "'", con, adOpenKeyset, adLockPessimistic
    6.    
    7.         If rs.EOF = True Then
    8.             MsgBox "Please Check Your Username And Password, ", vbQuestion, "Question"
    9.             txtUsername.SetFocus
    10.             Exit Sub
    11.         End If
    12.        
    13.         If Trim(txtPassword.Text) = Trim(rs(0)) Then
    14.             Username = txtUsername.Text
    15.             Unload Me
    16.            
    17.             If rs(1) = "Normal" Then
    18.                 frmMain.mnuAdmin.Enabled = False
    19.             End If
    20.             frmMain.Show
    21.         Else
    22.             MsgBox "Password Is Wrong, ", vbCritical, "Password Wrong"
    23.             txtPassword.SetFocus
    24.         End If
    25.        
    26.         If rs.State = 1 Then rs.Close
    27.         If con.State = 1 Then con.Close
    Last edited by Jamie_Garland; Jul 14th, 2009 at 01:35 PM.
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Error Help Please

    1) If that's your server's address... I'd change the code in the first post and block out the IP, the user name, the password and database name.... or you're inviting an attack on your database. Then I'd go ahead and change the password on the server jsut in case.
    2) "I dont use the pc for it i use my mysql on my webserver to connect too." -- if that's the case, then you may need to look to your host provider, as some do not allow access to the database from outside their servers. My host is like that. I can't get to the database from the outside, only from my cpanel or my web pages... it's a security thing.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Error Help Please

    Regardless of where in the world the database is located, you need to install the MySQL ODBC driver on your PC.

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: Error Help Please

    I've tried the connection and it works fine says it was connected but when i try run it on the server it gives me the above error still and highlights

    Connection Code Code:
    1. Public Sub Main()
    2.  
    3.     Set con = New ADODB.Connection
    4.     con.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=79.170.40.167;DATABASE=web167-money;USER=web167-money;PASSWORD=d82f1fc;"
    5.     Frm_Login.Show 1
    6.  
    7. End Sub

    Full Code Code:
    1. Private Sub cmdLogin_Click()
    2.  
    3. Set rs = New ADODB.Recordset
    4. If Trim(txtUsername.Text) = "" Then Exit Sub
    5. If con.State = 0 Then con.Open
    6.  
    7.     rs.Open "select password,usertype from Users where username='" & txtUsername.Text & "'", con, adOpenKeyset, adLockPessimistic
    8.    
    9.       If rs.EOF = True Then
    10.         MsgBox "Check User Name and Password"
    11.         txtUsername.SetFocus
    12.         Exit Sub
    13.     End If
    14.    
    15.    
    16.     If Trim(txtPassword.Text) = Trim(rs(0)) Then
    17.         Username = txtUsername.Text
    18.         Unload Me
    19.         If rs(1) = "Normal" Then
    20.           Frm_MDI.NU.Visible = False
    21.           Frm_MDI.B4.Visible = False
    22.           Frm_MDI.Rpt.Visible = False
    23.         End If
    24.         Frm_MDI.Show
    25.         Frm_dateWise.Show 1
    26.     Else
    27.       MsgBox "Password Is Wrong"
    28.       txtPassword.SetFocus
    29.     End If
    30. If rs.State = 1 Then rs.Close
    31. If con.State = 1 Then con.Close
    32.  
    33. End Sub

    the error is highlighted here in red and the screenshot above diplayes the error message i get?

    If Trim(txtUsername.Text) = "" Then Exit Sub
    If con.State = 0 Then con.Open
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  11. #11
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: Error Help Please

    1. What do you mean by run it on the server? Are you running this on a machine other than your pc, or you mean running this code against the database server.

    2. Did you test the connection using your ODBC control panel?

    So far what I have understood is that you have

    • a mysql database.
    • the database is remotely hosted.
    • you are unable to establish a connection from your vb6 program.
    • you are able to establish a connection using your mysql client.
    Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
    save a blobFileStreamDataTable To Text Filemy blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width