neuron Administrator
Posts : 38 Join date : 2009-08-06
| Subject: how to insert data into your access database vb.net Tue Aug 14, 2012 9:56 am | |
| here is a sample code: - Code:
-
Private Sub historyupdate()
Dim con As New OleDb.OleDbConnection Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Dim appath As String
Dim dsNewRow As DataRow
appath = Application.StartupPath()
con.ConnectionString = "PROVIDER=Microsoft.jet.oledb.4.0;data Source = " & appath & "\SISdatabase.mdb" sql = "SELECT * FROM History_log" da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "SISdatabase")
Dim cb As New OleDb.OleDbCommandBuilder(da) dsNewRow = ds.Tables("SISdatabase").NewRow()
dsNewRow.Item("xUsername") = UsernameTextBox.Text dsNewRow.Item("xHistory_type") = "A" dsNewRow.Item("xDescription") = "Logged in to the BCSIS" dsNewRow.Item("xDate") = Format(Now, "MM-dd-yyyy") dsNewRow.Item("xTime") = Format(Now, "hh:mm") ds.Tables("SISdatabase").Rows.Add(dsNewRow) da.Update(ds, "SISdatabase")
con.Close() User = UsernameTextBox.Text
End Sub
| |
|