M
mhmoud1990
Guest
cmd1.CommandText = "insert into tblinvoicedetails (invoiceNo)values(@InvoiceNo)"
With cmd1.Parameters
.AddWithValue("@InvoiceNo", NumericUpDown1.Value)
End with
cmd1.CommandText = "insert into tblInvoiceDetails (InvoiceNo, itemno, ItemName, Qt, Price, Total)values(@InvoiceNo,@itemno,@ItemName,@Qt,@Price,@Total)"
cmd1.Parameters.Add("@itemno", SqlDbType.Int)
cmd1.Parameters.Add("@ItemName", SqlDbType.VarChar)
cmd1.Parameters.Add("@Qt", SqlDbType.Int)
cmd1.Parameters.Add("@Price", SqlDbType.Money)
cmd1.Parameters.Add("@Total", SqlDbType.Money)
For x As Integer = 0 To DataGridView2.RowCount - 1
cmd1.Parameters(0).Value = DataGridView2.Rows(x).Cells(0).Value
cmd1.Parameters(1).Value = DataGridView2.Rows(x).Cells(1).Value
cmd1.Parameters(2).Value = DataGridView2.Rows(x).Cells(2).Value
cmd1.Parameters(3).Value = DataGridView2.Rows(x).Cells(3).Value
cmd1.Parameters(4).Value = DataGridView2.Rows(x).Cells(4).Value
cmd1.ExecuteNonQuery()
cmd1.Parameters.Clear()
Continue reading...
With cmd1.Parameters
.AddWithValue("@InvoiceNo", NumericUpDown1.Value)
End with
cmd1.CommandText = "insert into tblInvoiceDetails (InvoiceNo, itemno, ItemName, Qt, Price, Total)values(@InvoiceNo,@itemno,@ItemName,@Qt,@Price,@Total)"
cmd1.Parameters.Add("@itemno", SqlDbType.Int)
cmd1.Parameters.Add("@ItemName", SqlDbType.VarChar)
cmd1.Parameters.Add("@Qt", SqlDbType.Int)
cmd1.Parameters.Add("@Price", SqlDbType.Money)
cmd1.Parameters.Add("@Total", SqlDbType.Money)
For x As Integer = 0 To DataGridView2.RowCount - 1
cmd1.Parameters(0).Value = DataGridView2.Rows(x).Cells(0).Value
cmd1.Parameters(1).Value = DataGridView2.Rows(x).Cells(1).Value
cmd1.Parameters(2).Value = DataGridView2.Rows(x).Cells(2).Value
cmd1.Parameters(3).Value = DataGridView2.Rows(x).Cells(3).Value
cmd1.Parameters(4).Value = DataGridView2.Rows(x).Cells(4).Value
cmd1.ExecuteNonQuery()
cmd1.Parameters.Clear()
Continue reading...