1
我需要使我的storedprocedure更新,因爲messabox讀取datagridview的每個項目。它只保存消息箱讀取的最後一條記錄。需要幫助:(保存每個項目while循環vb.net
For Each row As DataGridViewRow In DataGridView1.Rows
Dim strunitprice As String = CDbl(row.Cells(7).FormattedValue) + Val(CDbl(TXTNET.Text))
'opening the connection
x = MessageBox.Show(CDbl(row.Cells(7).FormattedValue) + Val(CDbl(TXTNET.Text)))
If x = DialogResult.OK Then
Label27.Text = CDbl(row.Cells(7).FormattedValue) + Val(CDbl(TXTNET.Text))
End If
Dim dr5 As SqlDataReader
Dim myCommand As SqlCommand
connectme.Open()
myCommand = New SqlCommand("Select * from quotation", connectme)
dr5 = myCommand.ExecuteReader()
While dr5.Read()
connectme1.Close()
Dim c As New SqlCommand("updatequotation", connectme1)
Dim Adapter As SqlDataAdapter = New SqlDataAdapter(c)
c.CommandType = CommandType.StoredProcedure
c.Parameters.Add("@Customer_Name", SqlDbType.NVarChar).Value = txtclientname.Text
c.Parameters.Add("@Date_Today", SqlDbType.VarChar).Value = Label7.Text
c.Parameters.Add("@Net_Income", SqlDbType.VarChar).Value = TXTNET.Text
c.Parameters.Add("@Unit_Price", SqlDbType.VarChar).Value = Label27.Text
connectme1.Open()
c.ExecuteNonQuery()
connectme1.Close()
End While
dr5.Close()
connectme.Close()
Next row
End If