I am trying to Insert Data In my Ms Access Data Base from Vb.net
The Code Below I'm Using can Actually Save Data
Im using Parameterized Query
The Problem is when I save the Computed Values from a certain lines of Codes the Values of the sum will Change.
The Save Code Below:
Try
Dim sqlconn As New OleDb.OleDbConnection
Dim sqlquery As New OleDb.OleDbCommand
Dim connstring As String
connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\PlanX.mdb"
sqlconn.ConnectionString = connstring
sqlquery.Connection = sqlconn
sqlconn.Open()
sqlquery.CommandText = "INSERT INTO SchoolProfile([Grade1Female],[Grade1Male],[Grade1Total])VALUES(@Grade1Female,@Grade1Male,@Grade1Total )"
sqlquery.Parameters.AddWithValue("@Grade1Female", Grade1FemaleTextBox.Text)
sqlquery.Parameters.AddWithValue("@Grade1Male", Grade1MaleTextBox.Text)
sqlquery.Parameters.AddWithValue("@Grade1Total ", Grade1TotalTextBox.Text)
sqlquery.ExecuteNonQuery()
sqlconn.Close()
SchoolProfileTableAdapter.Fill(PlanXDataSet.SchoolProfile)
SchoolProfileDataGridView.Update()
MessageBox.Show("School Added")
Update()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
For the Compute Code: ( inserted at the Grade1Male TextBox)
Dim A As Double
Dim B As Double
Dim Result as Double
If Not Double.TryParse(Grade1FemaleTextBox.Text, A) Then
MessageBox.Show("INVALID")
Else
If Not Double.TryParse(Grade1MaleTextBox.Text, B) Then
MessageBox.Show("INVALID")
Else
result1 = A + B
Grade1TotalTextBox.Text = result1.ToString("")
End If
End If
Problem: After I Press the Save Button,
"INVALID" pops up from the message box
I can't seem to pinpoint the problem.
I also used toggle Breakpoint, but it wont show what is the problem.