473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

split data

I'm new to the C# world and learning as I go.
I have a question, I'm getting data back from my database such as

name/region.

How can I split this and only return the region?

Nov 15 '05 #1
5 2921
In article <#s**************@TK2MSFTNGP10.phx.gbl>,
cs*********@sbcglobal.net says...
I'm new to the C# world and learning as I go.
I have a question, I'm getting data back from my database such as

name/region.

How can I split this and only return the region?

If it is a string I.e. "John Doe/New York" you can use
string[] splitString = nameRegion.Split('/');

then you can access name using splitString[0] and [1] for the region.

--
Thanks
Mark mm
Nov 15 '05 #2
heres what i have and its not working, i'm a missing something or is the
syntax incorrect?

String User = request.Servervariables["AUTH_USER"];
string[] splitString = User.Split('/');
lblUser.text = User[2];

2 should be the user name only

"Mark mm" <ma********@hotmail.com> wrote in message
news:MP************************@News.CIS.DFN.DE...
In article <#s**************@TK2MSFTNGP10.phx.gbl>,
cs*********@sbcglobal.net says...
I'm new to the C# world and learning as I go.
I have a question, I'm getting data back from my database such as

name/region.

How can I split this and only return the region?

If it is a string I.e. "John Doe/New York" you can use
string[] splitString = nameRegion.Split('/');

then you can access name using splitString[0] and [1] for the region.

--
Thanks
Mark mm

Nov 15 '05 #3
In article <#N**************@TK2MSFTNGP10.phx.gbl>,
cs*********@sbcglobal.net says...
heres what i have and its not working, i'm a missing something or is the
syntax incorrect?

String User = request.Servervariables["AUTH_USER"];
string[] splitString = User.Split('/');
lblUser.text = User[2];

2 should be the user name only

Remember arrays are 0 indexed ie the second element will be 1.
If you put a break point at the lblUser.. statement and look at what
splitString contains it may reveal more.

--
Thanks
Mark mm
Nov 15 '05 #4
its actually blowing up on this \ when i try to split the string
it should be

String User = request.Servervariables["AUTH_USER"];
string[] splitString = User.Split('\'); 'receiving error here when
compiling.
lblUser.text = User[2];

does C# not like the backslash? \

"Mark mm" <ma********@hotmail.com> wrote in message
news:MP************************@News.CIS.DFN.DE...
In article <#N**************@TK2MSFTNGP10.phx.gbl>,
cs*********@sbcglobal.net says...
heres what i have and its not working, i'm a missing something or is the
syntax incorrect?

String User = request.Servervariables["AUTH_USER"];
string[] splitString = User.Split('/');
lblUser.text = User[2];

2 should be the user name only

Remember arrays are 0 indexed ie the second element will be 1.
If you put a break point at the lblUser.. statement and look at what
splitString contains it may reveal more.

--
Thanks
Mark mm

Nov 15 '05 #5
i got it working now
"Mike" <cs*********@sbcglobal.net> wrote in message
news:eE*************@TK2MSFTNGP11.phx.gbl...
its actually blowing up on this \ when i try to split the string
it should be

String User = request.Servervariables["AUTH_USER"];
string[] splitString = User.Split('\'); 'receiving error here when
compiling.
lblUser.text = User[2];

does C# not like the backslash? \

"Mark mm" <ma********@hotmail.com> wrote in message
news:MP************************@News.CIS.DFN.DE...
In article <#N**************@TK2MSFTNGP10.phx.gbl>,
cs*********@sbcglobal.net says...
heres what i have and its not working, i'm a missing something or is the syntax incorrect?

String User = request.Servervariables["AUTH_USER"];
string[] splitString = User.Split('/');
lblUser.text = User[2];

2 should be the user name only

Remember arrays are 0 indexed ie the second element will be 1.
If you put a break point at the lblUser.. statement and look at what
splitString contains it may reveal more.

--
Thanks
Mark mm


Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
0
by: j | last post by:
Hi, Anyone out there with binary search tree experience. Working on a project due tomorrow and really stuck. We need a function that splits a binary tree into a bigger one and smaller one(for a...
4
by: Brian Glen Palicia | last post by:
My goal is to accept input from the user into a text box and then parse the data using split(). The first step is this tiny program to test the split() function. It runs in IE, but in Mozilla it...
1
by: rcmail14872 | last post by:
I have a standard Access database with standard Forms and it is not split. I am going to run the upsizing wizard to change the data tables to SQL. I also need to split the database and I am going...
19
by: David Logan | last post by:
We need an additional function in the String class. We need the ability to suppress empty fields, so that we can more effectively parse. Right now, multiple whitespace characters create multiple...
3
by: Jan Hanssen | last post by:
Hi! I have a list of data in a textfile which is tab delimited. Each line is seperated by a VbCrLf. I want to collect this data in a multidimensional string array. I do not wish to use a...
14
by: Ron | last post by:
Hello, I am trying to parse a string on the newline char. I guess vbCrLf is a string constant. How can I parse my string - data - on the newline char? .... data += ASCII.GetString(buffer, 0,...
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
11
by: Brian | last post by:
I have been working on a data reception system.. I am still finding my way around Javascript, though I am accomplishing much. I just fixed a flaw that was really hard to find. The symptoms are...
1
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.