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.
Now I need to insert the value of text2,txt into the data base, this is my code so far,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"
it does not work but does not return error either?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
please help, thanks




Reply With Quote