 |
|
คือ ผมต้องการเพิ่มตู้มากกว่า1ตู้ในครั้งเดียว โดยข้อมูลของบริษัทข้อมูลเดียว

อันนี้ที่ผมเพิ่มข้อมูลลงฐานข้อมูลลงได้แค่ 1 ตู้อะคับ เลยอยากทราบว่า ถ้าจะเพิ่มหลายตู้ในครั้งเดียวต้องใส่ลูปหรือ if else ยังไงคับ
นี้โค้ดคับ
Code (VB.NET)
dataSt = New DataSet
adapter = New SqlDataAdapter("INSERT INTO Container(ContainerNo, Type, AgentName, DateIn, Time, Note, Status)VALUES('" & txtCon1.Text.Trim() & "'," & _
"'" & cboSize1.SelectedItem & "'," & _
"'" & cboAgent.Text & "'," & _
"'" & GetDateTime(dtpIN) & "'," & _
"'" & t & "'," & _
"'" & txtNote.Text & "'," & _
"'" & stu & "')", connection)
adapter.Fill(dataSt, "Container")
adapter = New SqlDataAdapter("INSERT INTO Agent(ContainerID, AgentName, Address, Email, Tel)VALUES((select MAX(ContainerID) from Container),'" & cboAgent.Text.Trim() & "'," & _
"'" & txtAddress.Text.Trim() & "'," & _
"'" & txtEmail.Text.Trim() & "'," & _
"'" & txtTel.Text.Trim() & "')", connection)
adapter.Fill(dataSt, "Agent")
คอลัม ContainerID ตั้งเป็น Identity คับ
Tag : .NET, Ms SQL Server 2008, VB.NET, VS 2010 (.NET 4.x)
|
|
 |
 |
 |
 |
Date :
2015-02-05 16:26:10 |
By :
kannikorn |
View :
926 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |