-
Mar 2nd, 2021, 06:55 AM
#1
Thread Starter
Junior Member
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:
Last edited by Shaggy Hiker; Mar 3rd, 2021 at 10:18 AM.
Reason: Added CODE tags.
-
Mar 2nd, 2021, 08:35 AM
#2
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.
-
Mar 2nd, 2021, 08:50 AM
#3
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"
-
Mar 2nd, 2021, 09:24 AM
#4
Thread Starter
Junior Member
Re: Connector ODBC Wizard
-
Mar 2nd, 2021, 06:37 PM
#5
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).
-
Mar 3rd, 2021, 04:59 AM
#6
Thread Starter
Junior Member
Re: Connector ODBC Wizard
Speak for you SamOscarBrown, if a person wants answer my question is his choose and not a waste of time.
-
Mar 3rd, 2021, 06:36 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|