Results 1 to 15 of 15

Thread: MySql Connection [HELP]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    MySql Connection [HELP]

    I need help in MYSQL connection,
    I wrote this script and it say that it doesnt found the database.

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Dim sConnect As ADODB.Connection
    4. Dim sRecord As ADODB.Record
    5. Dim sTrconnect As String
    6.  
    7. Set sConnect = New ADODB.Connection
    8. Set sRecord = New ADODB.Record
    9.  
    10. sTrconnect = "Driver={mySQL};Server=84.95.241.143;Port=2222;Option=131072;Stmt=;Database=private_test;Uid=private_test;Pwd=private_test;"
    11. sConnect.ConnectionString = sTrconnect
    12. sConnect.Open
    13. sRecord.Open ("select * from `test`")
    14.  
    15. Label1.Caption = sRecord("title") & sRecord("pass")
    16.  
    17.  
    18. End Sub

    What is the problem?


    BTW : The space in the Uid section in the connection script doesnt exist in the real script

    -k3pos

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: MySql Connection [HELP]

    I tried this too

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Dim sConnect As ADODB.Connection
    4. Dim sRecord As ADODB.Record
    5. Dim sTrconnect As String
    6.  
    7. Set sConnect = New ADODB.Connection
    8. Set sRecord = New ADODB.Record
    9.  
    10. sTrconnect = "Driver={mySQL};Server=http://megaserv.co.il;Port=2222;Option=131072;Stmt=;Database=private_test;Uid=private_test;Pwd=private_test;"
    11.  
    12. With sConnect
    13.     .ConnectionString = sTrconnect
    14.     .Open
    15. End With
    16.  
    17. With sRecord
    18.     .Open ("select * from `test`")
    19. End With
    20.  
    21. Label1.Caption = sRecord("title") & sRecord("pass")
    22.  
    23. End Sub

    Ther is a littel change in the connectionstring.
    It doesnt work either

    -k3pos

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: MySql Connection [HELP]

    I tried this too

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Dim sConnect As ADODB.Connection
    4. Dim sRecord As ADODB.Record
    5. Dim sTrconnect As String
    6.  
    7. Set sConnect = New ADODB.Connection
    8. Set sRecord = New ADODB.Record
    9.  
    10. sTrconnect = "Driver={MySQL ODBC 3.51 Driver};Server=megaserv.co.il;Port=2222;Database=private_test;User=private_test;Password=private_test;Option=3;"
    11.  
    12. With sConnect
    13.     .ConnectionString = sTrconnect
    14.     .Open
    15. End With
    16.  
    17. With sRecord
    18.     .Open ("select * from `test`")
    19. End With
    20.  
    21. Label1.Caption = sRecord("title") & sRecord("pass")
    22.  
    23. End Sub


    BY THE WAY THE DATABASE \ PASSWORD \ USERNAME ARE CORRECT

    -k3pos

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

    Re: MySql Connection [HELP]

    There was no need for 3 separate posts (you can Edit your posts to add the extra info), and no need to re-post the entire code each time - there was only one line that changed (but I had to read it all to find that out).

    You appear to be using connection strings for several different versions of connection software.. what version have you got installed on your computer? (you need to use the appropriate connection string for that).


    Has the server been set up to allow MySQL databases, or have you just copied the file(s) to the server? (it needs to be set up)

    Your port appears to be unusual.. has that port actually been set up on the server?

    Is the server aware of where the database is? (eg: if it is not in the 'root' directory, have you specified the path somewhere?)

    Can you connect using other software?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: MySql Connection [HELP]

    Sorry for the three posts i thought it will be easier like that..

    1)Yes the mysql is on the network
    2)No i dont try tog et other database every time its the same but other servernames
    3)The server allows MYSQL database
    4)The database exists

    I just need an exmaple. the exmples in the site "connectionstrings" arent good, they dont work,, i need real example.

    -k3pos

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

    Re: MySql Connection [HELP]

    I don't know what questions you were answering, but they weren't the ones I asked.

    They are real examples, and they work for many other people (tho I must admit that site is lacking explanations!).

    The important things to look at are the parts you have changed (such as the Port and Server), and ensure they are correct for the version of the MySQL connection software that you have installed on your computer. You are likely to find more detailed examples/explanations in the documentation that came with it, or on the web page you downloaded it from.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: MySql Connection [HELP]

    I need an example because i dont understand what to write in ther to make in work

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

    Re: MySql Connection [HELP]

    You've already got examples, and you can't get them working, so why do you want more of the same?

    I have already suggested the things you should check, and asked questions about things that are likely to be issues.

    Apart from that all I can do is re-iterate where to find more information about what to put in the parameters.. I have never used MySQL, so I can't explain anywhere near as well as the official documentation.

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: MySql Connection [HELP]

    4)The database exists
    What is the name and path of your database?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: MySql Connection [HELP]

    Path ?? ther is no path to mysql servers. they on inside the server.
    server : megaserv.co.il
    server_username : private
    server_password : private
    database_name : private_test
    database_username : private_test
    database_password : private_test

  11. #11
    New Member
    Join Date
    Sep 2006
    Posts
    6

    Re: MySql Connection [HELP]

    here is what I normally use

    create the connection string in a module

    VB Code:
    1. Module Module1
    2.     Public dbConnection As New ADODB.Connection
    3.     Public Inforec As New ADODB.Recordset, SQLSTR As String
    4.     Public dbServer As String, dbName As String, dbUser As String, dbPass As String
    5.     Public Emp_ID As String, Emp_Dept As String
    6.     Public Sub makeMysqlConn()
    7.         dbServer = "xxx.xxx.x.x"
    8.         dbName = "tracktime"
    9.         dbUser = "track"
    10.         dbPass = "track"
    11.         dbConnection = New ADODB.Connection
    12.         dbConnection.ConnectionString = "DRIVER={MySql ODBC 3.51 Driver};" _
    13.             & "SERVER=" & dbServer & ";" _
    14.             & "DATABASE=" & dbName & ";" _
    15.             & "UID=" & dbUser & ";PWD=" & dbPass & ";" _
    16.             & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
    17.  
    18.     End Sub
    19.  
    20. End Module


    then to connect i make a call to the sub
    Code:
     Private Sub frmTrack_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'call the connectin 
            makeMysqlConn()
            dbConnection.CursorLocation = ADODB.CursorLocationEnum.adUseClient
            dbConnection.Open()
            If dbConnection.State = 1 Then
                cboNames.Items.Clear()
                Inforec = New ADODB.Recordset
                With Inforec
                    SQLSTR = "Select * from employee"
                    .CursorLocation = ADODB.CursorLocationEnum.adUseClient
                    .Open(SQLSTR, dbConnection, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
                    If .RecordCount > 0 Then
                        .MoveFirst()
                        Do Until .EOF
                            cboNames.Items.Add(.Fields("name_id").Value.ToString & ". " & Inforec.Fields("name").Value.ToString)
                            .MoveNext()
    
                        Loop
                    End If
                    .Close()
                End With
                Inforec = Nothing
                dbConnection.Close()
    
    
            Else
                MsgBox("Connection failed", MsgBoxStyle.OkOnly, "Connection State")
            End If
        End Sub

    hope this helps
    Last edited by Hack; Feb 25th, 2007 at 05:46 AM. Reason: Edited out IP Address

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MySql Connection [HELP]

    CundiRob: I don't know if the IP address you put in your example was real or made up, but it looked real to me.

    Therefore, I have edited your post and removed it. It is not wise to post real IP address/user ids/passwords/etc in an open post on an open forum.

  13. #13
    New Member
    Join Date
    Sep 2006
    Posts
    6

    Re: MySql Connection [HELP]

    it is a internal ip on a test server that i reimage every other week. on a internal network

    but thanks

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    148

    Re: MySql Connection [HELP]

    I will try.

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Dim sConnect As ADODB.Connection
    4. Dim sRecord As ADODB.Record
    5. Dim sTrconnect As String
    6. Dim dbServer As String
    7. Dim dbName As String
    8. Dim dbUser As String
    9. Dim dbPass As String
    10.  
    11. Set sConnect = New ADODB.Connection
    12. Set sRecord = New ADODB.Record
    13. dbPass = "private"
    14. dbUser = "private"
    15. dbName = "private_test"
    16. dbServer = "megaserv.co.il"
    17.  
    18. sTrconnect = "DRIVER={MySql ODBC 3.51 Driver};" _
    19.             & "SERVER=" & dbServer & ";" _
    20.             & "DATABASE=" & dbName & ";" _
    21.             & "UID=" & dbUser & ";PWD=" & dbPass & ";" _
    22.             & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
    23.  
    24. With sConnect
    25.     .ConnectionString = sTrconnect
    26.     .Open
    27. End With
    28.  
    29. With sRecord
    30.     .Open ("select * from `test`")
    31. End With
    32.  
    33. Label1.Caption = sRecord("title") & sRecord("pass")
    34.  
    35. End Sub

    IT doesnt Work What Is The Problem?

    -k3pos
    Last edited by si_the_geek; Feb 25th, 2007 at 10:13 AM. Reason: corrected VBCode tags

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

    Re: MySql Connection [HELP]

    We can't tell - as you haven't told us what error you are getting, or where it is occurring.

    Note that the connection string needs the database username/password (which based on your previous post are both "private_test" rather than "private"), as you are connecting directly to the database, not to the server as a whole.

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