Click here to Skip to main content
15,889,462 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: i want add/edit/delete access table in database on vb2010 Pin
Richard MacCutchan1-Oct-14 4:37
mveRichard MacCutchan1-Oct-14 4:37 
SuggestionRe: i want add/edit/delete access table in database on vb2010 Pin
ZurdoDev2-Oct-14 5:00
professionalZurdoDev2-Oct-14 5:00 
QuestionMove a file according to a name inside the file itself. Pin
val566230-Sep-14 19:08
val566230-Sep-14 19:08 
AnswerRe: Move a file according to a name inside the file itself. Pin
Eddy Vluggen2-Oct-14 4:44
professionalEddy Vluggen2-Oct-14 4:44 
QuestionProblem with entity objects after refreshing model from database Pin
dilkonika30-Sep-14 11:34
dilkonika30-Sep-14 11:34 
AnswerRe: Problem with entity objects after refreshing model from database Pin
Eddy Vluggen2-Oct-14 4:49
professionalEddy Vluggen2-Oct-14 4:49 
QuestionAdd formatting to an excel cell in a loop Pin
Member 1111259730-Sep-14 6:11
Member 1111259730-Sep-14 6:11 
Questioncreate an xml request Pin
jim haras29-Sep-14 1:56
jim haras29-Sep-14 1:56 
Hi there,

I want to send a request message to a web service. I must send one xml request per contract. The xml request contains a least one person element. The person information is in a database table.If a contract contains 2 persons in the database then i must include them both in the request.

What i am trying to do is read the person information from the database table and place it into a dataset and then use a for each loop to create each of the persons elements. Unfortunately i am yet unsuccessful.
For example if there is only one person in the database for one specific contract i will send something like this:



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<cre:Contract>
<cre:CONTRACT xsi:type="con:CONTRACT">
<con:ID>1</con:ID>
<pers:PERSON xsi:type="pers:PERSON">
<pers:LASTNAME>John</pers:LASTNAME>
<pers:FIRSTNAME>Dow</pers:FIRSTNAME>
<pers:GENDER>M</pers:GENDER>
<pers:CITIZENSHIP>USA</pers:CITIZENSHIP>
<pers:ADDRESS xsi:type="pers:CC_ADDRESS_INPUT">
<pers:COUNTRY>USA</pers:COUNTRY>
<pers:ZIPCODE>12345</pers:ZIPCODE>
<pers:CITY>NY</pers:CITY>
<pers:STREET>Dummy Street</pers:STREET>
</pers:ADDRESS>
<pers:ROLE xsi:type="pers:ROLE">
<pers:ROLE>Person</pers:ROLE>
</pers:ROLE>
</pers:PERSON>
</cre:CONTRACT>
</cre:Contract>
</soapenv:Body>
</soapenv:Envelope>



If i have two persons i should be able to loop for these person in the dataset and send the following xml request:



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
<soapenv:Header>
</soapenv:Header>
<soapenv:Body>
<cre:Contract>
<cre:CONTRACT xsi:type="con:CONTRACT">
<con:ID>1</con:ID>
<pers:PERSON xsi:type="pers:PERSON">
<pers:LASTNAME>John</pers:LASTNAME>
<pers:FIRSTNAME>Dow</pers:FIRSTNAME>
<pers:GENDER>M</pers:GENDER>
<pers:CITIZENSHIP>USA</pers:CITIZENSHIP>
<pers:ADDRESS xsi:type="pers:CC_ADDRESS_INPUT">
<pers:COUNTRY>USA</pers:COUNTRY>
<pers:ZIPCODE>12345</pers:ZIPCODE>
<pers:CITY>NY</pers:CITY>
<pers:STREET>Dummy Street</pers:STREET>
</pers:ADDRESS>
<pers:ROLE xsi:type="pers:ROLE">
<pers:ROLE>Person</pers:ROLE>
</pers:ROLE>
</pers:PERSON>
<pers:PERSON xsi:type="pers:PERSON">
<pers:LASTNAME>Nick</pers:LASTNAME>
<pers:FIRSTNAME>New</pers:FIRSTNAME>
<pers:GENDER>M</pers:GENDER>
<pers:CITIZENSHIP>USA</pers:CITIZENSHIP>
<pers:ADDRESS xsi:type="pers:CC_ADDRESS_INPUT">
<pers:COUNTRY>USA</pers:COUNTRY>
<pers:ZIPCODE>12345</pers:ZIPCODE>
<pers:CITY>LA</pers:CITY>
<pers:STREET>LA Street</pers:STREET>
</pers:ADDRESS>
<pers:ROLE xsi:type="pers:ROLE">
<pers:ROLE>Person</pers:ROLE>
</pers:ROLE>
</pers:PERSON>
</cre:CONTRACT>
</cre:Contract>
</soapenv:Body>
</soapenv:Envelope>

The code for the "for each" loop is the following:
Dim con As SqlClient.SqlConnection
con = Me.TransactionController.CreateConnection()
con.Open()
Dim sda As New SqlDataAdapter()
Dim cmd As SqlCommand = New SqlCommand("GetPersons", con)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@ID", ID)
Dim r As SqlDataReader = cmd.ExecuteReader()
cmd.Connection = con
sda.SelectCommand = cmd
con.Close()
Dim ds As New DataSet()
sda.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Dim dt As DataTable
Dim dr As DataRow
dt = ds.Tables(0)

Dim person1 As New PERSON

For Each dr In dt.Rows

person1.FIRSTNAME = dr("FIRSTNAME").ToString()
person1.LASTNAME = dr("LASTNAME").ToString()
person1.GENDER = dr("GENDER").ToString()
person1.CITIZENSHIP = RTrim(dr("CITIZENSHIP").ToString())

' Address()
Dim addr1 As New ADDRESS
addr1.STREET = dr("STREET").ToString()
addr1.CITY = dr("CITY").ToString()
addr1.COUNTRY = dr("COUNTRY").ToString()
addr1.ZIPCODE = dr("ZIPCODE").ToString()
person1.ADDRESS = New ADDRESS() {addr1}

'ROLE()
Dim role1 As New ROLE
role1.ROLE1 = ROLE_VALUE.Person
role1.ROLE1Specified = True
person1.ROLE = New ROLE() {role1}


PERSON = New PERSON() {person1}

Exit For
Next dr
ds.Dispose()

End If

''''''--------------------------
Any ideas how to solve my issue?

Thank you in advance.
AnswerRe: create an xml request Pin
jim haras30-Sep-14 2:47
jim haras30-Sep-14 2:47 
GeneralRe: create an xml request Pin
Eddy Vluggen30-Sep-14 3:04
professionalEddy Vluggen30-Sep-14 3:04 
AnswerRe: create an xml request Pin
Richard Deeming30-Sep-14 3:28
mveRichard Deeming30-Sep-14 3:28 
GeneralRe: create an xml request Pin
jim haras30-Sep-14 3:49
jim haras30-Sep-14 3:49 
GeneralRe: create an xml request Pin
Richard Deeming30-Sep-14 7:42
mveRichard Deeming30-Sep-14 7:42 
QuestionCalculating total value of different items Pin
Kushal Kumar27-Sep-14 18:11
Kushal Kumar27-Sep-14 18:11 
AnswerRe: Calculating total value of different items Pin
Eddy Vluggen28-Sep-14 2:00
professionalEddy Vluggen28-Sep-14 2:00 
AnswerRe: Calculating total value of different items Pin
Dave Kreskowiak28-Sep-14 3:42
mveDave Kreskowiak28-Sep-14 3:42 
GeneralRe: Calculating total value of different items Pin
Richard MacCutchan28-Sep-14 3:50
mveRichard MacCutchan28-Sep-14 3:50 
GeneralRe: Calculating total value of different items Pin
Dave Kreskowiak28-Sep-14 3:59
mveDave Kreskowiak28-Sep-14 3:59 
GeneralRe: Calculating total value of different items Pin
Tim Carmichael28-Sep-14 6:07
Tim Carmichael28-Sep-14 6:07 
GeneralRe: Calculating total value of different items Pin
Dave Kreskowiak28-Sep-14 12:43
mveDave Kreskowiak28-Sep-14 12:43 
GeneralRe: Calculating total value of different items Pin
Mycroft Holmes28-Sep-14 14:05
professionalMycroft Holmes28-Sep-14 14:05 
Questiontif img print preview Pin
drago1127-Sep-14 12:07
drago1127-Sep-14 12:07 
AnswerRe: tif img print preview Pin
Dave Kreskowiak27-Sep-14 14:41
mveDave Kreskowiak27-Sep-14 14:41 
GeneralRe: tif img print preview Pin
drago1127-Sep-14 19:41
drago1127-Sep-14 19:41 
GeneralRe: tif img print preview Pin
Eddy Vluggen28-Sep-14 2:47
professionalEddy Vluggen28-Sep-14 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.