Long String

G

Guest

Hi

I'm sending a long string to a web service like this

field1,field2,field3,field4,field5,field6,field7+field1,field2,field3,field4,field5,field6,field7..

On the web service I need to read and to parse it in order to fill a DataSet and to update the DB,so do I have to use the String class' methods inside a Do-While or there is a more powerfull way to do it

Thks
 
D

Derek Harmon

Kenny said:
field1,field2,field3,field4,field5,field6,field7+field1,field2,field3,field4,field5,field6,field7...

do I have to use the String class' methods inside a Do-While or there is a more powerfull
way to do it?

I'd use String.Split( ), first on '+' to get an array of rows; then on ',' to get an array of
the columnal values for each row. It's certainly the most straightforward, provided the
separators ('+' and ',') don't occur within the values.

The classes in the System.Text.RegularExpressions namespace could also be used,
but I think a regexp would be overkill.


Derek Harmon
 
C

Cor

Hi kenny,

I would do a split on the ","

It is typed here so watch typos and errors
\\\
Dim mytext() as string = mysendedstring.split(","c)
dim mysingletext as string
for each mysingletext in mytext
'dosomething
next
///

I hope this helps,

Cor
Hi

I'm sending a long string to a web service like this:

field1,field2,field3,field4,field5,field6,field7+field1,field2,field3,field4
,field5,field6,field7...

On the web service I need to read and to parse it in order to fill a
DataSet and to update the DB,so do I have to use the String class' methods
inside a Do-While or there is a more powerfull way to do it?
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?S2Vubnk=?= said:
I'm sending a long string to a web service like this:

field1,field2,field3,field4,field5,field6,field7+field1,field2,field3,field4,field5,field6,field7...

On the web service I need to read and to parse it in order to fill a DataSet and to update the DB,so do I have to use the String class' methods inside a Do-While or there is a more powerfull way to do it?

Have a look at the string's 'Split' method or the 'Strings.Split' method.
 
J

Jay B. Harlow [MVP - Outlook]

Kenny,
Why a delimited string as opposed to sending an XML Node or a DataSet?

With an XML Node you don't have to worry if one of your fields have either a
+ or a , in them.

With a DataSet you don't have to worry about parsing it into a DataSet!

As the others have pointed you can use Split to parse your input string.

There are three Split functions in .NET:

Use Microsoft.VisualBasic.Strings.Split if you need to split a string based
on a specific word (string). It is the Split function from VB6.

Use System.String.Split if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter.

Use System.Text.RegularExpressions.RegEx.Split to split based
on matching patterns.

Hope this helps
Jay



Kenny said:
Hi

I'm sending a long string to a web service like this:

field1,field2,field3,field4,field5,field6,field7+field1,field2,field3,field4
,field5,field6,field7...

On the web service I need to read and to parse it in order to fill a
DataSet and to update the DB,so do I have to use the String class' methods
inside a Do-While or there is a more powerfull way to do it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top