Nate Bross
Well-known member
I have this code, which works; however, I dont want to select all events before I update. Is there a better way to do a simple Insert?
Code:
Dim drnew As System.Data.DataRow
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dbPath & ";")
cn.Open()
sql = "select * from events"
myDataAdapter = New OleDbDataAdapter (sql, cn)
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(myDataAdapter)
myDataAdapter.Fill(dsEventTemplate)
drnew = dsEventTemplate.Tables(0).NewRow()
drnew.Item("LocID") = TextBox1.Text
drnew.Item("EventDescription") = editEventDescription.Text
drnew.Item("EventStartTime") = editStartTime.Text
drnew.Item("EventEndTime") = editEndTime.Text
drnew.Item("EventCreationDate") = Now
dsEventTemplate.Tables(0).Rows.Add(drnew)
builder.GetUpdateCommand()
myDataAdapter.Update(dsEventTemplate)
Catch ex As Exception
MsgBox(ex.Message)
End Try
cn.Close()