I need help, I developed a simple Access database and I create a VB .Net user interface. I can't INSERT data into the Table here's my sample code... I'm only a beginner in VB.Net i hope you could help me with this one
Dim con As New OleDbConnection
Dim cmd As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Dim dr As DataRow
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Documents and Settings\Test\Desktop\Privilege.Net\PrivilegeCard\Database\dbPrivilegeSystem.mdb"
cmd.CommandText = "Select * From tblUsers;"
Try
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.Text
da.SelectCommand = cmd
da.Fill(ds, "tblUsers")
dr = ds.Tables("tblUsers").NewRow
'System.Convert.ToDateTime(dtPicker.Value).ToOADate()
'I've been trying to use this conversion for date thinking if this could help me fix my problem
dr(0) = txtUserN.Text
dr(1) = txtPass.Text
dr(2) = txtAccess.Text
dr(3) = dtPicker.Value
dr(4) = txtName.Text
dr(5) = txtPos.Text
dr(6) = cmbDept.Text
ds.Tables("tblUsers").Rows().Add(dr)
Dim cb As New OleDbCommandBuilder(da)
da.Fill(ds)
da.Update(ds, "tblUsers")
Catch ex As OleDbException
MessageBox.Show(ex.Message & " - " & ex.Source)
End Try