[resolved]access ado 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
Re: [resolved]access ado database
Thanx jlbeam the was perfect!!! :))
Next problem I am having is that I need to update a database (at www.planethax.com)
with the with the currentip table field ip.
the database for my app is
ip.mdb
table is CurrentIp
field is Ip
my database online is
mydb2
table is IpTbl
field is IpFld
any help with the code I need to update the online db with the local one will be greatly appreciated!
Thanks.