hello again :D i want to update my database if an enrollee have balance or dont have.. if they have balance , the record of payment of student will be updated..
here's my code :
Dim cn As OleDbConnection
If TextBox1.Text = "" Then
MsgBox("Enter a Student Number! ", MsgBoxStyle.Information, "Warning")
ElseIf TextBox1.TextLength = 9 Then
con = New OleDbConnection("Provider= Microsoft.ACE.oledb.12.0; Data Source=C:\Users\user\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
Dim ewaaa As String = "Select * from Payment where StudentNumber = '" & TextBox1.Text & "'"
com = New OleDbCommand(ewaaa, con)
con.Open()
com.ExecuteNonQuery()
rid = com.ExecuteReader
rid.Read()
If (rid.HasRows) Then
TextBox1.Text = rid(2)
cn = New OleDbConnection("Provider=Microsoft.ace.oledb.12.0;Data Source=C:\Users\user\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
cn.Open()
cmda = New OleDbCommand("UPDATE Payment SET DateAndTime = '" & Label1.Text & "' And AmountPaid = '" & TextBox5.Text & "' And Balances = '" & TextBox7.Text & "' ", cn)
cmda.ExecuteNonQuery() <<<== error
cn.Close()
MsgBox("Transaction Updated", MsgBoxStyle.Information, "Update")
Else
con = New OleDbConnection("Provider=Microsoft.ace.oledb.12.0;Data Source=C:\Users\user\Desktop\CBFMNHS Enrollment System\CBFMNHS Enrollment System\bin\Debug\Enrollment System.accdb")
da.SelectCommand = New OleDbCommand("Select* from Payment", con)
cmd = New OleDbCommandBuilder(da)
If con.State = ConnectionState.Closed Then con.Open()
ds = New DataSet
da.Fill(ds, "Payment")
ds.Tables("Payment").Rows.Add()
lastrow = ds.Tables("Payment").Rows.Count - 1
myrow = ds.Tables("Payment").Rows.Item(lastrow)
myrow.Item("DateAndTime") = Label1.Text
myrow.Item("StudentNumber") = TextBox1.Text
myrow.Item("NameofStudent") = TextBox2.Text
myrow.Item("ModeofPayment") = ComboBox1.Text
myrow.Item("IDFees") = TextBox3.Text
myrow.Item("PTAFees") = TextBox6.Text
myrow.Item("MiscellaneousFee") = TextBox4.Text
myrow.Item("AmountPaid") = TextBox5.Text
myrow.Item("Balances") = TextBox7.Text
ds.Tables("Payment").GetChanges()
cmd.GetInsertCommand()
da.Update(ds, "Payment")
MsgBox("Successfully Saved!")
con.Close()
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
ComboBox1.SelectedIndex = -1
End If
End If
the problem with this code. : error occured says "Data type mismatch in criteria expression." please help me..