Sent DataSet to Web service
WEB SERVICE
<WebMethod()> _
Public Sub SetDataSet(ByVal dataSet As DataSet)
Dim dr As DataRow
Dim sSQL As String
For Each dr In DataSet.Tables(0).Rows
sSQL = "INSERT INTO TESTDATA(USERID,USERNAME) VALUES ("
sSQL = sSQL & " '" & dr("USERID") & "' ,"
sSQL = sSQL & " '" & dr("USERNAME") & "' )"
Mod_Center.Mod_ExceuteSQL(sSQL)
Next
End Sub
End Class
--------------------------
VB .net
Dim ss As New SERVICE.Service1
Dim dt As New Data.DataTable
Dim table1 As New Data.DataTable
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
table1.Columns.Add("USERID") '' ใช้ในการแทนค่าตัวแปลใน Webservice
table1.Columns.Add("USERNAME") '' ใช้ในการแทนค่าตัวแปลใน Webservice
'' อ่านค่าจาก GridView
Dim Gw As DataGridView = DataGridView1
For i As Integer = 0 To DataGridView1.Rows.Count() - 2
table1.Rows.Add(Gw.Rows(i).Cells("Item_Id").Value, Gw.Rows(i).Cells("Item_Name").Value)
Next
'' เก็บข้อมูล dataTable TO Dataset
Dim set1 As DataSet = New DataSet("tmp_aa")
set1.Tables.Add(table1)
ss.SetDataSet(set1)
End Sub
http://www.หมอไอสึแอร์เซอร์วิส.com
By @itkorat.com 555++
<WebMethod()> _
Public Sub SetDataSet(ByVal dataSet As DataSet)
Dim dr As DataRow
Dim sSQL As String
For Each dr In DataSet.Tables(0).Rows
sSQL = "INSERT INTO TESTDATA(USERID,USERNAME) VALUES ("
sSQL = sSQL & " '" & dr("USERID") & "' ,"
sSQL = sSQL & " '" & dr("USERNAME") & "' )"
Mod_Center.Mod_ExceuteSQL(sSQL)
Next
End Sub
End Class
--------------------------
VB .net
Dim ss As New SERVICE.Service1
Dim dt As New Data.DataTable
Dim table1 As New Data.DataTable
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
table1.Columns.Add("USERID") '' ใช้ในการแทนค่าตัวแปลใน Webservice
table1.Columns.Add("USERNAME") '' ใช้ในการแทนค่าตัวแปลใน Webservice
'' อ่านค่าจาก GridView
Dim Gw As DataGridView = DataGridView1
For i As Integer = 0 To DataGridView1.Rows.Count() - 2
table1.Rows.Add(Gw.Rows(i).Cells("Item_Id").Value, Gw.Rows(i).Cells("Item_Name").Value)
Next
'' เก็บข้อมูล dataTable TO Dataset
Dim set1 As DataSet = New DataSet("tmp_aa")
set1.Tables.Add(table1)
ss.SetDataSet(set1)
End Sub
http://www.หมอไอสึแอร์เซอร์วิส.com
By @itkorat.com 555++
ไม่มีความคิดเห็น