Hello there,
I face this error message when I try to save a new record in Table: viruses_analysis, I would like to use the same way in the code below, but where is the error?
please be informed that I used the same way in other applications and worked very fine.
I'm confused.
Thanks in advance.
Dim SSQl As String = "select * from viruses_analysis"
Dim SAdapter As New OleDbDataAdapter(SSQl, Con)
Dim SDataSet As New DataSet
Dim RowsCount As Integer
Dim dsNewRow As DataRow
If Con.State = ConnectionState.Closed Then
Con.Open()
SAdapter.Fill(SDataSet, "SavingSalaryDetails")
RowsCount = SDataSet.Tables("SavingSalaryDetails").Rows.Count
dsNewRow = SDataSet.Tables("SavingSalaryDetails").NewRow()
dsNewRow.Item("VirDate") = dtDate.Value.Date
dsNewRow.Item("VirDay") = dtDate.Value.Day
dsNewRow.Item("VirMonth") = dtDate.Value.Month
dsNewRow.Item("VirYear") = dtDate.Value.Year
dsNewRow.Item("PatID") = PatID
dsNewRow.Item("PatName") = PatName
dsNewRow.Item("HIV") = cmbHIV.Text
dsNewRow.Item("HBSAG") = cmbHBSAG.Text
dsNewRow.Item("HCV") = cmbHCV.Text
dsNewRow.Item("VDRL") = cmbVDRL.Text
dsNewRow.Item("COST") = Val(txtCost.Text)
dsNewRow.Item("PAID") = Val(txtPaidValue.Text)
dsNewRow.Item("user") = "Admin"
' Apply the new row
Dim cb As New OleDb.OleDbCommandBuilder(SAdapter)
SDataSet.Tables("SavingSalaryDetails").Rows.Add(dsNewRow)
SAdapter.Update(SDataSet, "SavingSalaryDetails")
Con.Close()
SDataSet.Reset()
ClearControls()
Else
SAdapter.Fill(SDataSet, "SavingSalaryDetails")
RowsCount = SDataSet.Tables("SavingSalaryDetails").Rows.Count
dsNewRow = SDataSet.Tables("SavingSalaryDetails").NewRow()
dsNewRow.Item("VirDate") = dtDate.Value.Date
dsNewRow.Item("VirDay") = dtDate.Value.Day
dsNewRow.Item("VirMonth") = dtDate.Value.Month
dsNewRow.Item("VirYear") = dtDate.Value.Year
dsNewRow.Item("PatID") = PatID
dsNewRow.Item("PatName") = PatName
dsNewRow.Item("HIV") = cmbHIV.Text
dsNewRow.Item("HBSAG") = cmbHBSAG.Text
dsNewRow.Item("HCV") = cmbHCV.Text
dsNewRow.Item("VDRL") = cmbVDRL.Text
dsNewRow.Item("COST") = Val(txtCost.Text)
dsNewRow.Item("PAID") = Val(txtPaidValue.Text)
dsNewRow.Item("user") = "Admin"
' Apply the new row
Dim cb As New OleDb.OleDbCommandBuilder(SAdapter)
SDataSet.Tables("SavingSalaryDetails").Rows.Add(dsNewRow)
SAdapter.Update(SDataSet, "SavingSalaryDetails")
Con.Close()
SDataSet.Reset()
ClearControls()
End If