|
|
|
Error ตอนAdd แบบ หลาย Record แต่ add record เดียวได้นะครับ ขอคำแนะนำด้วยครับ |
|
|
|
|
|
|
|
ERROR ตอนAdd หลาย record ตอน Add Record เดียวไม่มีปัญหา
sql = "INSERT INTO Tranfer (Tran_ID,Tran_Date, Status_ID) VALUES (@Tran_ID, @Tran_Date, @Status_ID)"
sql &= "INSERT INTO Tran_Detail (Tran_ID,Part_No,Part_Qty,Station_ID) VALUES (@Tran_ID,@Part_No, @Part_Qty, @Station_ID)"
For i As Integer = 0 To DataGridView1.RowCount - 1
If Not DataGridView1.Rows(i).IsNewRow Then
With cm
.Parameters.Add(New SqlParameter("@Tran_ID", DataGridView1.Rows(i).Cells(0).Value))
.Parameters.Add(New SqlParameter("@Part_No", DataGridView1.Rows(i).Cells(1).Value))
.Parameters.Add(New SqlParameter("@Part_Qty", DataGridView1.Rows(i).Cells(2).Value))
.Parameters.Add(New SqlParameter("@Station_ID", DataGridView1.Rows(i).Cells(3).Value))
.Parameters.Add(New SqlParameter("@Tran_Date", DataGridView1.Rows(i).Cells(4).Value))
.Parameters.Add(New SqlParameter("@Status_ID", DataGridView1.Rows(i).Cells(5).Value))
End With
cm.ExecuteNonQuery()
cm.Parameters.Clear()
End If
Next
===================================================================================
Table
Tranfer Tran_Detail
-------------------------------------------------------
(PK)Tran_ID <--------->Tran_ID(FK)
Tran_Date Part_No
Status_ID Part_Qty
Dtation_ID
Tag : .NET, Ms SQL Server 2008, VS 2012 (.NET 4.x)
|
|
|
|
|
|
Date :
2013-11-13 16:13:23 |
By :
Keeperza |
View :
642 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Table
Tranfer Tran_Detail
-------------------------------------------------------
(PK)Tran_ID <--------->Tran_ID(FK)
Tran_Date Part_No
Status_ID Part_Qty
station_ID
|
|
|
|
|
Date :
2013-11-13 16:17:58 |
By :
Keeperza |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|