inserting onto Ms access using vb.NEt

  • Thread starter Thread starter Guest
  • Start date Start date
Add a System DSN called myAccessDb (or whatever) that points to your MsAccess
database using the ODBC Data Source Administrator.

imports System.Data.Odbc

dim connOdbc as new odbcconnection
dim cmdOdbc as new odbccommand
dim nRowsAffected as integer

connOdbc.ConnectionString = "DSN=myAccessDb;"
connOdbc.Open()
cmdOdbc.Connection = connOdbc
cmdOdbc.CommandText = "INSERT INTO tablename (col1, col2) VALUES (1, 2);"
nRowsAffected = cmdOdbc.ExecuteNonQuery()
connOdbc.Close()
 
Back
Top