Strings ~ Help Please

  • Thread starter Thread starter Brad Isaacs
  • Start date Start date
B

Brad Isaacs

Using ASP.NET 2.0 , code behind with VB.NET and an SQL Server 2000 database

Inside my dropdown list box I am using an SQL DataSource to select the
following data

SELECT RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact,
c.phone As PriPortPhone
FROM mppaContacts c

Dropdown list box works well .....


Example "Bart Simpson"

First_name = Bart
Last_name = Simpson

DropDownList -->> RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact
ANS:: "Bart Simpson"

How can I parse the blank space I am trying to PARSE it based on the space
that I placed into the string
found in the DropDownlist box???





UPDATE mppaContacts
SET
[Name_First] = @FirstName
[Name_last] = @LastName
[phone] = @phone


Any ideas would be greatly appreciated........not sure how to extract the
individual names and place them into their specific fields.


Thanks in advance

~Brad
 
Brad said:
Using ASP.NET 2.0 , code behind with VB.NET and an SQL Server 2000 database

Inside my dropdown list box I am using an SQL DataSource to select the
following data

SELECT RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact,
c.phone As PriPortPhone
FROM mppaContacts c

Dropdown list box works well .....


Example "Bart Simpson"

First_name = Bart
Last_name = Simpson

DropDownList -->> RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact
ANS:: "Bart Simpson"

How can I parse the blank space I am trying to PARSE it based on the space
that I placed into the string
found in the DropDownlist box???





UPDATE mppaContacts
SET
[Name_First] = @FirstName
[Name_last] = @LastName
[phone] = @phone


Any ideas would be greatly appreciated........not sure how to extract the
individual names and place them into their specific fields.


Thanks in advance

~Brad

You could just split the string on the space character, that creates an
array containing the first name and last name:

Dim names As String()
names = name.Split(" "C)

This of course requires that neither the first name nor the last name
contains any spaces. If they do, at the time of joining them caused a
loss of information that you can not automatically recover, as you no
longer know if it was the first name or last name that contained the
extra space.
 
Brad Isaacs wrote:
<backposted/>

If you're positive that the first name doesn't contain spaces of its
own (a fair assumption, I guess), then you can split the string at the
first space position:

<aircode>
'Assuming FullName came from the DropDownList
Dim P As Integer = FullName.IndexOf(" "c)
Dim FirstName As String = FullName.Substring(0, P)
Dim LastName As String = FullName.Substring(P+1)
</aircode>

HTH.

Regards,

Branco.
 
Hi Branco,

Thank you very much for your input (code). I was able to tweak my code and
using your code snippet, get the result I was looking for in my application.

Thanks again,

~Brad

Branco Medeiros said:
Brad Isaacs wrote:
<backposted/>

If you're positive that the first name doesn't contain spaces of its
own (a fair assumption, I guess), then you can split the string at the
first space position:

<aircode>
'Assuming FullName came from the DropDownList
Dim P As Integer = FullName.IndexOf(" "c)
Dim FirstName As String = FullName.Substring(0, P)
Dim LastName As String = FullName.Substring(P+1)
</aircode>

HTH.

Regards,

Branco.
Using ASP.NET 2.0 , code behind with VB.NET and an SQL Server 2000
database

Inside my dropdown list box I am using an SQL DataSource to select the
following data

SELECT RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact,
c.phone As PriPortPhone
FROM mppaContacts c

Dropdown list box works well .....

Example "Bart Simpson"

First_name = Bart
Last_name = Simpson

DropDownList -->> RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS
Contact
ANS:: "Bart Simpson"

How can I parse the blank space I am trying to PARSE it based on the
space
that I placed into the string
found in the DropDownlist box???

UPDATE mppaContacts
SET
[Name_First] = @FirstName
[Name_last] = @LastName
[phone] = @phone

Any ideas would be greatly appreciated........not sure how to extract the
individual names and place them into their specific fields.

Thanks in advance

~Brad
 
Hi Göran,

Thank you very much for your input. It has proven helpful.

Thanks again,

~Brad'



Göran Andersson said:
Brad said:
Using ASP.NET 2.0 , code behind with VB.NET and an SQL Server 2000
database

Inside my dropdown list box I am using an SQL DataSource to select the
following data

SELECT RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS Contact,
c.phone As PriPortPhone
FROM mppaContacts c

Dropdown list box works well .....


Example "Bart Simpson"

First_name = Bart
Last_name = Simpson

DropDownList -->> RTRIM(c.Name_First) + ' ' + RTRIM(c.Name_Last) AS
Contact
ANS:: "Bart Simpson"

How can I parse the blank space I am trying to PARSE it based on the
space
that I placed into the string
found in the DropDownlist box???





UPDATE mppaContacts
SET
[Name_First] = @FirstName
[Name_last] = @LastName
[phone] = @phone


Any ideas would be greatly appreciated........not sure how to extract the
individual names and place them into their specific fields.


Thanks in advance

~Brad

You could just split the string on the space character, that creates an
array containing the first name and last name:

Dim names As String()
names = name.Split(" "C)

This of course requires that neither the first name nor the last name
contains any spaces. If they do, at the time of joining them caused a loss
of information that you can not automatically recover, as you no longer
know if it was the first name or last name that contained the extra space.
 
Back
Top