Results 1 to 3 of 3

Thread: [resolved]help...Newby with database

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Resolved [resolved]help...Newby with database

    Ok this is my fisrt attempt at working with data bases
    I have made a form that creates an access database, then creates a row.
    Code:
    Private Sub Command1_Click()
    
       Text2.Text = GetPublicIP()
           Dim conCatalog As ADOX.Catalog
        On Error Resume Next
        Set conCatalog = New ADOX.Catalog
        conCatalog.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                          "Data Source='C:\vb6files\FtpIpFiles\ip.mdb'"
        
        MsgBox "A new Microsoft JET database named IP.mdb has been created"
        
        Set conCatalog = Nothing
        
        Dim conIp As ADODB.Connection
        Dim strSQL As String
        
        Set conIp = New ADODB.Connection
        conIp.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                          "Data Source='C:\vb6files\FtpIpFiles\ip.mdb'"
        
        strSQL = "CREATE TABLE CurrentIp (" & _
                 "Ip VarChar(32));"
        
        conIp.Execute strSQL
        
        MsgBox "A table named IpAddy has been added to the IP.mdb database"
    Now I need to insert the value of text2,txt into the data base, this is my code so far,
    Code:
    Private Sub cmdInsertIp_Click()
        Dim conIp As New ADODB.Recordset
        Dim conCatalog As New ADODB.Connection
    
    conCatalog.Open "Provider='Microsoft.JET.OLEDB.4.0';" & _
                          "Data Source='C:\vb6files\FtpIpFiles\ip.mdb'"
       
    
    If conIp.Supports(adAddNew) Then
    
            With conIp
                .AddNew
                .Fields("ip") = Me.Text2.Text
                .Update
            End With
            
            MsgBox "text2.txt has been added"
        End If
        
        
        Me.Text2.SetFocus
    
      
        
    
    
        
        Set conIp = Nothing
        conCatalog.Close
        Set conCatalog = Nothing
    End Sub
    it does not work but does not return error either?
    please help, thanks
    Last edited by planethax; Apr 11th, 2005 at 01:15 AM. Reason: resolved

  2. #2
    Junior Member
    Join Date
    Nov 2003
    Posts
    22

    Re: help...Newby with database

    I replied to this question in the Classic VB forum:

    http://www.vbforums.com/showthread.php?t=333318

    Regards,

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    651

    Thumbs up Re: help...Newby with database

    Thank You

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