Results 1 to 7 of 7

Thread: Connector ODBC Wizard

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2021
    Posts
    18

    Connector ODBC Wizard

    why when i lunch the program it required me the user and the password, that i already set i n the code above:
    Code:
    Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    Private Sub Form_Load()
        Dim cnMySql As New rdoConnection
        Dim rdoQry As New rdoQuery
        Dim server, db, user, pwd As String
        Dim insertQry As New rdoQuery
        Dim rdoRS1 As rdoResultset
        Open "C:\Users\Paolo\Desktop\attivita_1\mysql.ini" For Input As #1
        Line Input #1, server
        Line Input #1, db
        Line Input #1, user
        Line Input #1, pwd
        Close #1
        
        cnMySql.CursorDriver = rdUseOdbc
        cnMySql.Connect = "Driver={MySQL ODBC 3.51 Driver};Server=" & server & ";Database=" & db & ";User=" & nome & "; Password=" & pass & ";Option=3;"
        cnMySql.EstablishConnection
        rdoQry.SQL = "SELECT SUM(quantita) AS q_art, codice_articolo  FROM magazzino GROUP BY codice_articolo"
        rdoQry.RowsetSize = 1
    
        
        Set rdoQry.ActiveConnection = cnMySql
        Set rdoRS = rdoQry.OpenResultset(rdOpenKeyset, rdConcurRowVer)
        
        Do Until rdoRS.EOF
            insertQry.SQL = "INSERT INTO magazzino_media (codice_articolo,quantita,data_giacenza) VALUES ('" & rdoRS!codice_articolo & "', '" & rdoRS!q_art & "','" & Format$(Now, "yyyy-mm-dd") & "')"
            Debug.Print insertQry.SQL
            Set insertQry.ActiveConnection = cnMySql
            Set rdoRS1 = insertQry.OpenResultset(rdOpenKeyset, rdConcurRowVer)
            insertQry.Close
            Set insertQry = Nothing
            rdoRS.MoveNext
        Loop
       Form1.Show
       Sleep 1000
       Unload Me
    End Sub
    Wizard:

    Name:  Cattura.PNG
Views: 415
Size:  30.9 KB
    Last edited by Shaggy Hiker; Mar 3rd, 2021 at 10:18 AM. Reason: Added CODE tags.

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: Connector ODBC Wizard

    Look at the variable names in your Line Input statements and compare them to the variable names in your SQL connection string.

    Good luck.

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Connector ODBC Wizard

    To prevent such mistakes in the future add "Option Explicit" as the first line in every code module (Form, Class, Module, UserControl)

    You can have this automatically added for new code modules using the following setting:
    Tools -> Options -> Check "Require Variable Declaration"

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2021
    Posts
    18

    Re: Connector ODBC Wizard

    thanks

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Connector ODBC Wizard

    I took a quick gander (that's a 'quick look', not an adult male goose) at your recent posts today....it appears you are just stabbing at things. You haven't figured out how to put code tags around your posted code (which, I expect, are slightly modified copies of someone else's work).

    May I make a recommendation before you go much farther (and WASTE a lot of peoples' time here on this site)? If so, buy a book about VB6. Read it. Do the example codes in it. Use the Help (MSDN). And THEN, if you have questions, by all means, ask here.

    Sorry if I sound rude (don't mean to), but it would serve you a whole lot better if you learn via a book first rather than grabbing code and pasting into an application. Also, as mentioned above, USE Option Explicit on each form (that can be set as a default in VB6 IDE).

    Good luck.
    Sam I am (as well as Confused at times).

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2021
    Posts
    18

    Re: Connector ODBC Wizard

    Speak for you SamOscarBrown, if a person wants answer my question is his choose and not a waste of time.

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Connector ODBC Wizard

    Sorry...was just offering ADVICE to help YOU.
    Sam I am (as well as Confused at times).

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