update command

  • Thread starter Thread starter enrico via DotNetMonster.com
  • Start date Start date
E

enrico via DotNetMonster.com

my update command works just fine and i have three fields that represents
double because they are number fields and in my database i gave them a
default value of 0. but when i change those values an error occurs saying
something like data truncate on that field. here's my update code by the way:


Dim myquery As New MyClasslibrary.MyHelper
Form3.connect(myquery)

Dim freeserv As Integer = 0

If CheckBox1.Checked Then
freeserv = 1
Else
freeserv = 0
End If

With myquery
Dim id As String = ""

.runQuery(" UPDATE tbltrcclient tc SET Lastname = '" & TextBox3.
Text & "', Firstname = '" & TextBox4.Text & "', " _
& " tc.Barangay = '" & ComboBox1.Text & "' " _
& " where tc.ClientID = '" & TextBox1.Text & "' ")

.runQuery(" Update tbltrcservice ts set Date = '" &
DateTimePicker1.Value.ToString("yyyy-MM-dd") & "' , `Sitio/Purok` = '" &
TextBox5.Text & "', ts.Barangay = '" & ComboBox2.Text & "', " _
& " NatureofService = '" & ComboBox3.Text & "', NoOfHectares = '"
& TextBox7.Text & "', NoOfLiters = '" & TextBox9.Text & "', " _
& " TotalAmount = '" & TextBox11.Text & "', Free = '" & freeserv.
ToString & "', AmountPaid = '" & TextBox12.Text & "', " _
& " AmountRemaining = '" & TextBox13.Text & "', Remarks = '" &
TextBox14.Text & "' where ts.ClientID = '" & TextBox1.Text & "' ")

MessageBox.Show("Data Updated.")

End With

my double fields are TotalAmount, AmountPaid and AmountRemaining. can anyone
help how to get rid of the error?
 
.runQuery(" Update tbltrcservice ts set Date = '" &
DateTimePicker1.Value.ToString("yyyy-MM-dd") & "' , `Sitio/Purok` = '"
& TextBox5.Text & "', ts.Barangay = '" & ComboBox2.Text & "', " _
& " NatureofService = '" & ComboBox3.Text & "',
NoOfHectares = '"
& TextBox7.Text & "', NoOfLiters = '" & TextBox9.Text & "', " _
& " TotalAmount = '" & TextBox11.Text & "', Free = '" &
freeserv.
ToString & "', AmountPaid = '" & TextBox12.Text & "', " _
& " AmountRemaining = '" & TextBox13.Text & "', Remarks =
'" &
TextBox14.Text & "' where ts.ClientID = '" & TextBox1.Text & "' ")

You should really use SQL Parameters.
 
Enrico,

As you don't use parameters, then try it first with one value, this is a
mesh.

Cor
 
Back
Top