Dim constr As String = "Data Source=zumzamzaa-note;Initial Catalog=data;User ID=zumzamzaa;Password=038416391;"
Dim conn As New SqlConnection(constr)
conn.Open()
Dim sql As String = "INSERT INTO Sell(Date, CustomerName, Count, Total, Product_Name) VALUES(@Datts, @C, @CO, @t, @P)"
Dim cmd As New SqlCommand(sql, conn)
Dim a As String
Dim b As String
Dim y As String
Dim x As String = TextBox5.Text
Dim z As String = Session("dates").ToString
For Each mm As GridViewRow In GridView2.Rows
a = DirectCast(mm.Cells(0).Text, String)
b = DirectCast(mm.Cells(1).Text, String)
y = DirectCast(mm.Cells(3).Text, String)
cmd.Parameters.AddWithValue("Datts", z)
cmd.Parameters.AddWithValue("C", x)
cmd.Parameters.AddWithValue("CO", b)
cmd.Parameters.AddWithValue("t", y)
cmd.Parameters.AddWithValue("P", a)
Next
Dim afeter As Integer = cmd.ExecuteNonQuery
If afeter < 1 Then
MsgBox("เกิดข้อผิดพลาดขึ้นในระบบ")
Else
MsgBox("จัดเก็บข้อมูลเรียบร้อยแล้ว")
End If