16-02-19, 12:02 AM
عند الضعط على زر اضافة يتم اضافة السجل و بعدها تظهر رسالة . Invalid conversion by the string in type double
ما السبب ؟؟
الحقول بالقاعدة من نوع number
وهذا كود :
ما السبب ؟؟
الحقول بالقاعدة من نوع number
وهذا كود :
كود :
Imports System.Data.OleDb
Public Class ProFrm
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
End Sub
Private Sub ProFrm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Calc()
If txtPris.Text = "" Then Exit Sub
If cmoms.Text = "" Then Exit Sub
Dim x As Double
Dim y As Double
Dim z As Double
y = cmoms.SelectedItem.ToString
x = CDbl(txtPris.Text)
z = x * y / 100
txtmoms.Text = z
txttotalt.Text = CDbl(x + z)
End Sub
Private Sub btnsave_Click(sender As Object, e As EventArgs) Handles btnsave.Click
Try
cmd = New OleDbCommand("Insert Into TBL_Products ( Pro_Code, Pro_Name, Pro_Price, Pro_Moms, Pro_Totalt) values
(@Pro_Code, @Pro_Name, @Pro_Price, @Pro_Moms, @Pro_Totalt)", con)
cmd.Parameters.Add(New OleDbParameter("@Pro_Code", OleDbType.Integer)).Value = txtcode.Text
cmd.Parameters.Add(New OleDbParameter("@Pro_Name", OleDbType.VarChar)).Value = txtDes.Text
cmd.Parameters.Add(New OleDbParameter("@Pro_Price", OleDbType.Double)).Value = txtPris.Text
cmd.Parameters.Add(New OleDbParameter("@Pro_Moms", OleDbType.Double)).Value = txtmoms.Text
cmd.Parameters.Add(New OleDbParameter("@Pro_Totalt", OleDbType.Double)).Value = txttotalt.Text
con.Open()
cmd.ExecuteNonQuery()
MsgBox("Done!")
txtcode.Text = " "
txtDes.Text = " "
txtPris.Text = " "
txtmoms.Text = " "
txttotalt.Text = " "
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub ToolStripButton7_Click(sender As Object, e As EventArgs) Handles ToolStripButton7.Click
Me.Close()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
End Sub
Private Sub txttotalt_TextChanged(sender As Object, e As EventArgs) Handles txttotalt.TextChanged
Calc()
End Sub
Private Sub txtPris_TextChanged(sender As Object, e As EventArgs) Handles txtPris.TextChanged
End Sub
Private Sub txtmoms_TextChanged(sender As Object, e As EventArgs) Handles txtmoms.TextChanged
End Sub
Private Sub cmoms_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmoms.SelectedIndexChanged
Calc()
End Sub
End Class