如何在VB.net中将多个文本框值写入XML文件?

时间:2014-01-30 06:10:30

标签: asp.net xml vb.net wcf xml-parsing

我是vb.net的初学者。 请告诉我如何从vb.net中的多个textbox.text生成xml文件 我在sid中有错误。数组边界不能出现在类型说明符中“ 我在Dim ds.ReadXml(ds)“期望结束语”中也有错误

Protected Sub btnChkService_Click(sender As Object, e As EventArgs) Handles btnChkService

    Dim cid As Int32
    Dim sid As Int32
    Dim tid As String
    sid = Convert.ToInt32(TxtSiteId.Text)
    cid = Convert.ToInt32(TxtCompId.Text)
    tid = TxtTokenId.Text
    Dim client As ServiceRef.DemoService()
    Dim DataSet As client.GetEmployees(sid, cid, tid)
    Dim ds As DataSet
    'Dim StringReader sr As New StringReader(data)'
    'Dim DataSet ds As New DataSet(data)'
    Dim ds.ReadXml(ds)
    'string st = Server.MapPath("XMLFile.xml")'
    Dim Data.WriteXml(Data)

End Sub

1 个答案:

答案 0 :(得分:1)

不确定这会有效(没有测试过,也没有时间),但这可能会让你朝着正确的方向前进:

Dim cid As Int32
Dim sid As Int32
Dim tid As String
sid = Convert.ToInt32(TxtSiteId.Text)
cid = Convert.ToInt32(TxtCompId.Text)
tid = TxtTokenId.Text
Dim client As New ServiceRef.DemoService()
Dim ds As DataSet

client.Open()
ds = client.GetEmployees(sid, cid, tid)
ds.WriteXml(Server.MapPath("XMLFile.xml"))

client.Close()

Dim用于声明指定类型的变量。它不用于调用对象上的方法(尽管可以在Dim语句中分配方法的返回。)

在Dim语句中声明和初始化变量的示例是上面的行:

Dim client As New ServiceRef.DemoService()