|
Posted by: Billion Dollar Boy on 2010-06-02, 07:24:11
I do a lot of coding in VB.net. Although it may be slightly different, VB and C# are very similar. In VB.net, you need to create a connection string to the Access database, and that would change depending on whether it was a .mdb, .accdb, or adp version of MS Access. If you are using MS Access 2007, which is .accdb format, this would be the VB.net connection and sql command sample: Dim Fullpath As String = "C:\path_to_your_access_database\ " Dim DatabasePath As String = Fullpath & "nameOfYourDatabase.accdb " Dim cn As New OleDbConnection( "Provider= Microsoft.ACE.OLEDB.12.0;Data Source= " & DatabasePath) Dim StrFill As String = "INSERT INTO YourTableName (fieldname1) VALUES (' " & textbox1.text & "') " cn.Open() cmd = New OleDbCommand(StrFill, cn) sqlcount = cmd.ExecuteNonQuery cn.Close() |