hi all,
im sorry if this question is already been posted before.im not sure how to check every single textboxes that key in by user..if it is empty string then convert to 0 auto..
my code is:
Dim con As New SqlConnection(connectionString)
Dim cmd4 As New SqlCommand
cmd4.Connection = con
Try
con.Open()
cmd4.CommandText = "insert into dailyloco_status ([KTMB],[IRCON],[SMH],[total],[requirement],[short],[type],[datetime]) " _
& " values (@KTMB, @IRCON,@SMH,@total,@requirement,@short,@type,@datetime)"
Dim p1 As New SqlParameter("@KTMB", SqlDbType.Int)
Dim p2 As New SqlParameter("@IRCON", SqlDbType.Int)
Dim p3 As New SqlParameter("@SMH", SqlDbType.Int)
Dim p4 As New SqlParameter("@total", SqlDbType.Int)
Dim p5 As New SqlParameter("@requirement", SqlDbType.Int)
Dim p6 As New SqlParameter("@short", SqlDbType.Int)
Dim p7 As New SqlParameter("@type", SqlDbType.SmallInt)
Dim p8 As New SqlParameter("@datetime", SqlDbType.VarChar)
For i As Integer = 0 To 7 Step 1
If i = 0 Then
p1.Value = Integer.Parse(TextBox12.Text)
p2.Value = Integer.Parse(TextBox13.Text)
p3.Value = Integer.Parse(TextBox14.Text)
p4.Value = Integer.Parse(TextBox15.Text)
p5.Value = 0
p6.Value = 0
p7.Value = 1
ElseIf i = 1 Then
p1.Value = Int64.Parse(TextBox20.Text)
p2.Value = Int64.Parse(TextBox21.Text)
p3.Value = Int64.Parse(TextBox22.Text)
p4.Value = Int64.Parse(TextBox23.Text)
p5.Value = Int64.Parse(TextBox41.Text)
p6.Value = Int64.Parse(TextBox42.Text)
p7.Value = 2
totdaily_loco()
ElseIf i = 2 Then
p1.Value = Int64.Parse(TextBox24.Text)
p2.Value = Int64.Parse(TextBox25.Text)
p3.Value = Int64.Parse(TextBox26.Text)
p4.Value = Int64.Parse(TextBox27.Text)
p5.Value = Int64.Parse(TextBox43.Text)
p6.Value = Int64.Parse(TextBox76.Text)
p7.Value = 3
ElseIf i = 3 Then
p1.Value = Integer.Parse(TextBox28.Text)
p2.Value = Integer.Parse(TextBox29.Text)
p3.Value = Integer.Parse(TextBox30.Text)
p4.Value = Integer.Parse(TextBox31.Text)
p5.Value = Integer.Parse(TextBox77.Text)
p6.Value = Integer.Parse(TextBox78.Text)
p7.Value = 4
ElseIf i = 4 Then
p1.Value = Integer.Parse(TextBox32.Text)
p2.Value = Integer.Parse(TextBox33.Text)
p3.Value = Integer.Parse(TextBox34.Text)
p4.Value = Integer.Parse(TextBox35.Text)
p5.Value = Integer.Parse(TextBox79.Text)
p6.Value = Integer.Parse(TextBox80.Text)
p7.Value = 5
ElseIf i = 5 Then 'total
p1.Value = Integer.Parse(TextBox36.Text)
p2.Value = Integer.Parse(TextBox37.Text)
p3.Value = Integer.Parse(TextBox38.Text)
p4.Value = Integer.Parse(TextBox39.Text)
p5.Value = Integer.Parse(TextBox81.Text)
p6.Value = Integer.Parse(TextBox82.Text)
p7.Value = 6
ElseIf i = 6 Then
p1.Value = Integer.Parse(TextBox44.Text)
p2.Value = Integer.Parse(TextBox45.Text)
p3.Value = Integer.Parse(TextBox46.Text)
p4.Value = Integer.Parse(TextBox47.Text)
p5.Value = 0
p6.Value = 0
p7.Value = 6
End If
p8.Value = DateTime.Now
cmd4.Parameters.Add(p1)
cmd4.Parameters.Add(p2)
cmd4.Parameters.Add(p3)
cmd4.Parameters.Add(p4)
cmd4.Parameters.Add(p5)
cmd4.Parameters.Add(p6)
cmd4.Parameters.Add(p7)
cmd4.Parameters.Add(p8)
cmd4.ExecuteNonQuery()
cmd4.Parameters.Clear()
Next
Catch ex As Exception
MesgBox(ex.Message.ToString())
Finally
con.Close()
End Try