1

I'm beginner in vb.net. Please tell me about all how can i generate xml file from multiple textbox.text in vb.net i have error in sid"Array bounds cannot appear in type specifiers" and i have also error in Dim ds.ReadXml(ds) "End of statement expected"

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
5
  • Returning DataSets from a WCF service is generally considered bad practice - return a custom object (or collection of custom objects) instead, as that will preserve interoperability. Besides, have you seen what a DataSet looks like when it's serialized? Commented Jan 30, 2014 at 7:13
  • ReadXml() is a method belonging to the DataSet class - you're trying to declare the method (and you're trying to pass a DataSet as the argument, which you can't do). Can you post both the implementation of GetEmployees() and the XML you're trying to generate (i.e., what it should look like)? Commented Jan 30, 2014 at 7:15
  • please can you do this in code i can't understand what you are asking i can't changes in WCF its requirment Commented Jan 30, 2014 at 7:28
  • What format of XML are you looking for? Take a look at the link for ReadXml() I put in the comment and see if that helps you get a direction. Commented Jan 30, 2014 at 7:33
  • how i put this {client.GetEmployees(sid, cid, tid)} value in dataset after that i want this dataset into xml file Commented Jan 30, 2014 at 7:51

1 Answer 1

1

Not sure this will work (haven't tested it and don't have time to), but this might get you going in the right direction:

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 is used to declare a variable of the specified type. It's not used to call methods on an object (though the return of a method can be assigned in a Dim statement).

An example of declaring and initializing a variable in a Dim statement is the line above:

Dim client As New ServiceRef.DemoService()
Sign up to request clarification or add additional context in comments.

5 Comments

ds = client.GetEmployees(sid, cid, tid) give error "value of type 'String' cannot be converted to 'System.Data.DataSet'"
Then GetEmployees is returning a string, not a DataSet. And before you ask, there's no easy way to turn a string into a DataSet.
then what i use instead of dataset i want getemployee value into xml
[Dim ds As String] [client.Open()] [ ds = client.GetEmployees(sid, cid, tid)] [ Dim ds2 As New DataSet] [ ds2.ReadXml(ds)] [ ds2.WriteXml(Server.MapPath("XMLFile1.xml"))] [ client.Close()] its build succeeded but after btnclk give this error An exception of type 'System.ArgumentException' occurred in mscorlib.dll but was not handled in user code Additional information: Illegal characters in path.
Dim ds As String client.Open() ds = client.GetEmployees(sid, cid, tid) Dim sr As New StringReader(ds) Dim ds2 As New DataSet(ds) ds2.ReadXml(sr) ds2.WriteXml(Server.MapPath("XMLFile.xml")) ds2.WriteXmlSchema(Server.MapPath("XMLSchema.xsd")) client.Close() @Tim Its working thanks & regard

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.