C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

C#


Posted Date: 04 May 2007      Posted By: Smita      Member Level: Silver     Points: 2   Responses: 12



Hello Guys

I retrieve value from database in the form of
a,b,c,d,e

but i got ,a,b,c,d,e

So i don't want first , How to remove first comma
Plz tell me
Thank you





Responses

Author: Shivshanker Cheral    05 May 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi
according to your questio what i suggest is you can use LEFT() function if this doesnot solve then explain your question



Author: Smita    05 May 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

int count1 = ds.Tables[0].Rows.Count;

for (int i = 0; i < count1; i++)
{
string s="";

s = s + "," + ds.Tables[0].Rows[i][0].ToString();
}
i got value ,a,b,c,d
but i want a,b,c,d



Author: Smita    05 May 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

i have written code this
/***********

int count1 = ds.Tables[0].Rows.Count;

for (int i = 0; i < count1; i++)
{
string s="";

s = s + "," + ds.Tables[0].Rows[i][0].ToString();
}
TextBox1.Text = TextBox1.Text+s.ToString();

i got value ,a,b,c,d
but i want a,b,c,d



Author: Shivshanker Cheral    05 May 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi
int count1 = ds.Tables[0].Rows.Count;

for (int i = 0; i < count1; i++)
{
string s="";

s = s + ds.Tables[0].Rows[i][0].ToString() + ",";
}
TextBox1.Text = TextBox1.Text+s.ToString();

s = left(s,length(s)-1);



Author: Smita    05 May 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

s = left(s,length(s)-1);

left is not show in intellisence
this is not working



Author: Smita    05 May 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

i m using c# code

s = left(s,length(s)-1);

this is not working



Author: Smita    05 May 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

s = left(s,length(s)-1);

sir this is not working in c#



Author: Shivshanker Cheral    05 May 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

steps to be done:

1. first u need to add a reference of "Microsoft.VisualBasic";

2. using Microsoft.VisualBasic;

3.
TextBox1.Text = Strings.Right(s, s.Length - 1));



Author: vishal     05 May 2007Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

change a little bit in your code. use the following code:
int count1 = ds.Tables[0].Rows.Count;
string s="";
for (int i = 0; i < count1; i++)
{

if (i==0)
s = ds.Tables[0].Rows[i][0].ToString();
else
s = s + "," + ds.Tables[0].Rows[i][0].ToString();
}
TextBox1.Text = TextBox1.Text+s.ToString();

you will get the proper value
and use the statement --> string s=""; outside the for loop otherwise it will return only last row's value.



Author: Smita    05 May 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

1. first u need to add a reference of "Microsoft.VisualBasic";

2. using Microsoft.VisualBasic;

3.
TextBox1.Text = Strings.Right(s, s.Length - 1));

this code is running but output is abcd
but i want a,b,c,d



Author: Smita    05 May 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

Thank You Sir


Author: Shivshanker Cheral    05 May 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi vishal
your code will runt but what hapens we need to check one more extra condition every time means if i have 1000 characater then i need to test the conditino 1000 times! so instead of testing 1000 times once removing the character is better choice!.......



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Roles
Previous : How to select treenode by javascript?
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use