 |
|
คือสร้างฟังก์ชั่นการสร้าง text file ไว้ที่ web service แล้วทีนี้เขียนโค้ดในส่วนของโปรแกรมเพื่อส่งค่ามาเขียนไฟล์ text ใน webservice
ปรากฎว่า โปรแกรมมันมีข้อมูลทั้งหมด เช่น 3 บรรทัด แต่พอเขียนผ่าน webservice แล้วมันมีแค่บรรทัดเดียวซึ่งเป็นข้อมูลตัวสุดท้าย
เหมือนนมันไม่เขียนต่อแต่มันเขียนทับค่ะ
ใครรู้ช่วยด้วยนะค่ะ ด่วนจริงๆ ต้องส่งงานวันนี้ด้วย ฮือๆ
เป็น VB.NET นะค่ะ
นี่เป็นโค้ดของ webservice นะค่ะ
Code (VB.NET)
<WebMethod()> _
Public Function CteateFile(ByVal datafile As String) As String
Dim Mydate As String = Format(Today, "MMddyyy")
Dim MyTimeH, MyTimeM, MyTimeS, Times As Double
Dim re As String
MyTimeH = Format(DateTime.Now, "HH")
MyTimeM = (Format(DateTime.Now, "mm"))
MyTimeS = Format(DateTime.Now, "ss")
Times = Fix(((MyTimeH * 3600) + (MyTimeM * 60) + MyTimeS) / 10)
Dim myFile As String = "C:\CN3\" + Mydate + "-" + Times.ToString + ".txt" '// file location.
Dim myWriter As New IO.StreamWriter(myFile)
myWriter.WriteLine(datafile)
myWriter.close()
re = "0k"
Return re
End Function
และนี้เป็นโค้ดหน้าโปรแกรมที่ส่งค่าไป webservice
Code (VB.NET)
Private Sub FinishBT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FinishBT.Click
Dim DataText As String
Dim dtext As String = ""
For Each myItem As ListViewItem In CountLV.Items
DataText = (myItem.Text & "," & myItem.SubItems(2).Text)
WebDB.CteateFile(dtext).ToString()
Next
MsgBox("finish")
End Sub
ตัวอย่าผลลัพธ์ที่ไม่เขียนผ่าน Webservice
001,10
002,15
003,5
ตัวอย่างผลลัพธ์ที่เขียนผ่าน Webservice
003,5 มันเหลือแค่บรรทัดเดียวค่ะ ฮือๆๆๆ
Tag : .NET, VB.NET
|
ประวัติการแก้ไข 2011-11-19 13:10:03 2011-11-19 13:10:24
|
 |
 |
 |
 |
Date :
2011-11-19 13:06:59 |
By :
Orang_e |
View :
1045 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |