Checking special charactersin table

Posted by Lakn2 under Regular Expressions on 7/15/2011 | Points: 10 | Views : 1275 | Status : [Member] | Replies : 11
hi i am checking all column values if any special characters are there .it is working fine but it returns last column two times
and i want better code than below code (means it contains 4 loops so it takes more time so i want to execute less time)\

 SqlDataAdapter da = new SqlDataAdapter("select * from task1", cn);
DataTable dt = new DataTable();

da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{

string str = dt.Rows[i][j].ToString();
string str1 = "#$%^@";
for (int k = 0; k < str1.Length; k++)
{
for (int l = 0; l < str.Length ; l++)
{
if (str1[k] == str[l])
{
Response.Write(dt.Rows[i][j].ToString());
}
}

}
}
Response.Write("<br>");
}


Thanks&Regards
LakshmiNarayana Nalluri.



Responses

Posted by: Michael Caine on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
SqlDataAdapter da = new SqlDataAdapter("select * from task1", cn);
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count; j++)
{
char ch = dt.rows[i][j];
if(ch == '#' || ch == '$' || ch == '%' || ch == '^' || ch == '@')
Response.Write(dt.Rows[j].ToString());
}
Response.Write("<br>");
}

[url="http://www.cegonsoft-ftp.com"]Cegonsoft[/url]

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
hi Michael Caine

your code is not working can you check it once.

Thanks&Regards
LakshmiNarayana Nalluri.

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Michael Caine on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
Change
char ch = dt.rows[j];

to

char ch = dt.rows[ i ][ j ];

[url="http://www.cegonsoft-ftp.com"]Cegonsoft[/url]

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
No Michaet it is not working ,same error in ch=dt.rows[i]

Thanks&Regards
LakshmiNarayana Nalluri.

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Usejoy78 on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii........................vats up

Brassbuilder wholesale hardware

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/16/2011 [Member] Starter | Points: 25

Up
0
Down
hi Useofjoy78
i had posted one code ,but i want better code in performance issue and it should executes less time.

Thanks&Regards
LakshmiNarayana Nalluri.

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Usejoy78 on: 7/16/2011 [Member] Starter | Points: 25

Up
0
Down
how to create signature link

Brassbuilder wholesale hardware

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: DotnetGuy on: 7/18/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
1)do you want to display the rows which contains special characters?
2)do you want just count of the rows which contains special characters?
Please clarify





Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/18/2011 [Member] Starter | Points: 25

Up
0
Down
i want to display the cell number of excel which contains special characters because i am binding my excel to gridview

Thanks&Regards
LakshmiNarayana Nalluri.

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/19/2011 [Member] Starter | Points: 25

Up
0
Down
Hi DotnetGuy ,
Any updates ?

Thanks&Regards
LakshmiNarayana Nalluri.

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 7/19/2011 [Member] Starter | Points: 25

Up
0
Down
still i did n't get exacy answer.give me any suggessions.

Thanks&Regards
LakshmiNarayana Nalluri.

Lakn2, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response