Dim statement As String
Dim conn As ADODB.Connection
' db_file is the Access database's file name.
' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
conn.Open
' Compose the INSERT statement.
statement = "INSERT INTO Addresses " & _
"(Name, Street, City, State, Zip) " & _
" VALUES (" & _
"'" & txtName.Text & "', " & _
"'" & txtStreet.Text & "', " & _
"'" & txtCity.Text & "', " & _
"'" & txtState.Text & "', " & _
"'" & txtZip.Text & "'" & _
")"
' Execute the statement.
conn.Execute statement, , adCmdText
' Close the connection.
conn.Close
|