connecting to ms access with vb6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #76
    Here are the column names you should have in your database:

    STEP 4

    Make sure the database table column names are the following:

    (a) UserID

    (b) Name

    (c) Address

    (d) Phone

    (e) Email


    WARNING:

    VB must have the proper column names to know where to add for data


    (1) Do you have the column names in your access database?
    (2) Could you delete the form in your access database?

    Comment

    • yoda
      Contributor
      • Dec 2006
      • 291

      #77
      Originally posted by Dököll
      It's ok, Yoda:

      (1) Why do you have textboxes in access
      (2) Did you also bulid a form in Access?
      The only form you need should the VB form

      (3) Do you still have a table called Yoda ni Access?
      (4) Does that table have 5 columns?

      I can't recall what I posted as column names for you, in a bit...
      1) no i don't have any text box's in access

      2)no i didn't make form in access just VB

      3) yes i do have a table called Yoda in access

      4) No the table only as two called User ID and Password

      thanks Yoda

      Comment

      • Dököll
        Recognized Expert Top Contributor
        • Nov 2006
        • 2379

        #78
        -Can you go in table named Yoda
        -Delete User ID and Password columns
        -Add the below column names instead
        -Be sure to add them as noted, ok

        (a) UserID

        (b) Name

        (c) Address

        (d) Phone

        (e) Email

        This is the information your VB form knows to be valid

        Do the above then let me know, ok. This must be frustrating to you. Just know there is a light at the end of the tunnel :-)

        Comment

        • yoda
          Contributor
          • Dec 2006
          • 291

          #79
          Originally posted by Dököll
          -Can you go in table named Yoda
          -Delete User ID and Password columns
          -Add the below column names instead
          -Be sure to add them as noted, ok

          (a) UserID

          (b) Name

          (c) Address

          (d) Phone

          (e) Email

          This is the information your VB form knows to be valid

          Do the above then let me know, ok. This must be frustrating to you. Just know there is a light at the end of the tunnel :-)
          No its not really that frustrating just taking long the i thought.

          Ok it still says the "my_databas e As Database" is wrongand i have done every thing u said so far but i could be wrong. so what do we do?

          Comment

          • Dököll
            Recognized Expert Top Contributor
            • Nov 2006
            • 2379

            #80
            You have my address, take a snapshot of your access database, send it to me, I'll add notes to it, if this can help sort things out...

            If you would rather continue here, that'll be excellent. Simply add the column names I told you, we'll go from there.

            Comment

            • yoda
              Contributor
              • Dec 2006
              • 291

              #81
              Originally posted by Dököll
              You have my address, take a snapshot of your access database, send it to me, I'll add notes to it, if this can help sort things out...

              If you would rather continue here, that'll be excellent. Simply add the column names I told you, we'll go from there.
              I have add the column names and what do i do now?

              and what do u mean i have your address cuz if u mean e-mail nope i don't.

              Yoda

              Comment

              • Dököll
                Recognized Expert Top Contributor
                • Nov 2006
                • 2379

                #82
                Fantastic now, fir up your VB app to add to those fields you just added to Access, tell me what's happening...

                Comment

                • Dököll
                  Recognized Expert Top Contributor
                  • Nov 2006
                  • 2379

                  #83
                  Be sure to add below code, Yoda, that's what you need to load info to Yoda1.mdb. And make sure the database is closed:

                  Code:
                  Private Sub cmdAdd_Click()  
                  
                          Dim my_database As Database 
                  
                          Set my_database = OpenDatabase("C:\Yoda1.mdb")
                  
                          my_database.Execute "insert into Yoda1.Yoda(UserID, Name, Address, Phone, Email) Values('" & Text1.Text & "','" & Text2.Text & "' , '" & Text3.Text & "' , '" & Text4.Text & "','" & Text5.Text & "')"
                          my_database.Close ' 
                    
                  Text1.Text="" 
                  Text2.Text="" 
                  Text3.Text="" 
                  Text4.Text="" 
                  Text5.Text="" 
                  
                  End Sub

                  Comment

                  • yoda
                    Contributor
                    • Dec 2006
                    • 291

                    #84
                    Originally posted by Dököll
                    Be sure to add below code, Yoda, that's what you need to load info to Yoda1.mdb. And make sure the database is closed:

                    Code:
                    Private Sub cmdAdd_Click()  
                    
                            Dim my_database As Database 
                    
                            Set my_database = OpenDatabase("C:\Yoda1.mdb")
                    
                            my_database.Execute "insert into Yoda1.Yoda(UserID, Name, Address, Phone, Email) Values('" & Text1.Text & "','" & Text2.Text & "' , '" & Text3.Text & "' , '" & Text4.Text & "','" & Text5.Text & "')"
                            my_database.Close ' 
                      
                    Text1.Text="" 
                    Text2.Text="" 
                    Text3.Text="" 
                    Text4.Text="" 
                    Text5.Text="" 
                    
                    End Sub
                    Ok i have put the code in and it still doesn't work it still doesn't like "my_databas e As Database" in the code wat do we do?

                    Comment

                    • Dököll
                      Recognized Expert Top Contributor
                      • Nov 2006
                      • 2379

                      #85
                      Where is your database located?

                      Comment

                      • rajaaryan44
                        New Member
                        • Mar 2007
                        • 11

                        #86
                        Dim strCnn As String
                        (Connection string )
                        strCnn = "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
                        "Data Source=" & App.Path & "\WareHouse_Mai nt.mdb;Persist Security Info=False;Jet OLEDB:Database Password= raju"
                        (/Connection string )
                        Set cnn = New ADODB.Connectio n
                        cnn.Open strCnn

                        End Sub

                        Comment

                        • yoda
                          Contributor
                          • Dec 2006
                          • 291

                          #87
                          Originally posted by Dököll
                          Where is your database located?
                          my database is located on the C:\. because thats where u told me to put it.

                          Comment

                          • Dököll
                            Recognized Expert Top Contributor
                            • Nov 2006
                            • 2379

                            #88
                            Great!

                            (1) Are you saying your code is exactly as the below?

                            Code:
                            Private Sub cmdAdd_Click()  
                            
                                    Dim my_database As Database 
                            
                                    Set my_database = OpenDatabase("C:\Yoda1.mdb")
                            
                                    my_database.Execute "insert into Yoda1.Yoda(UserID, Name, Address, Phone, Email) Values('" & Text1.Text & "','" & Text2.Text & "' , '" & Text3.Text & "' , '" & Text4.Text & "','" & Text5.Text & "')"
                                    my_database.Close ' 
                              
                            Text1.Text="" 
                            Text2.Text="" 
                            Text3.Text="" 
                            Text4.Text="" 
                            Text5.Text="" 
                            
                            End Sub
                            (2) And are you also saying, you have a table in your database with these column names?

                            UserID, Name, Address, Phone, Email

                            (3) And when you attempt to submit to these fields, do data get added in?

                            I am baffled Yoda, it works at my end. In fact, I worked on this code for us both and will be posting the very code to a project I have been working on for months.

                            Did you make copies of this database like I suggested, by the way?

                            You will find saving a copy every now and then, saves you a lot of work :-)

                            Comment

                            • yoda
                              Contributor
                              • Dec 2006
                              • 291

                              #89
                              1) yes the code is exactly as below.

                              2)yes i do have a table with these column names.

                              3) I have attempted but no data ever got in the table.

                              4) yes it baffles me too but i guess it just won't work on my computer i just might have to try on a different one. and yes i have made copies, i have been saving but doesn't really help. oh well we tried.
                              Last edited by yoda; Mar 24 '07, 01:17 AM. Reason: forgot to get rid of quote

                              Comment

                              • Dököll
                                Recognized Expert Top Contributor
                                • Nov 2006
                                • 2379

                                #90
                                Did you send me your information?

                                Comment

                                Working...