Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > '' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.

Reply
Thread Tools

'' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.

 
 
rote
Guest
Posts: n/a
 
      01-23-2008
Hello Everyone,
I'm retrieving data from Excel from my asp.net page
The WorkSheet name is StatusPasPorts.

When i remove the column [Account Reference No.] it does work fine but if i
use it i get error :
'' is not a valid name. Make sure that it does not include invalid
characters or punctuation and that it is not too long.

SELECT [Event Date],[Mobile Number],[Event Type Name],[Identification
Method],[Customer DOB],[Account Reference No.] FROM [StatusPasPorts$] where
[Mobile Number] = '" + this.TextBox1.Text.ToString() + "' order by [Event
Date] ASC

Any ideas what i'm missing.

Thanks in Advance




 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      01-23-2008
rote explained on 23-1-2008 :
> Hello Everyone,
> I'm retrieving data from Excel from my asp.net page
> The WorkSheet name is StatusPasPorts.
>
> When i remove the column [Account Reference No.] it does work fine but if i
> use it i get error :
> '' is not a valid name. Make sure that it does not include invalid characters
> or punctuation and that it is not too long.
>
> SELECT [Event Date],[Mobile Number],[Event Type Name],[Identification
> Method],[Customer DOB],[Account Reference No.] FROM [StatusPasPorts$] where
> [Mobile Number] = '" + this.TextBox1.Text.ToString() + "' order by [Event
> Date] ASC
>
> Any ideas what i'm missing.
>
> Thanks in Advance


I have no experience with querying excel in this way, but the
errormessage suggests that there might be an invalid character. I think
the "." in [Account Reference No.] is a candidate. Try removing it
(also from the excel file).

Some other remarks:
I take it "TextBox1" is a TextBox? Then the .Text property is already a
string, so you don't need the ".ToString()".

What if someone used a "mobile number" the string "x' OR '1'='1"?
Then your query would return everything. This is "sql injection". In
normal database queries you can use parameters to guard against that.

Hans Kesting


 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      01-23-2008
also, test to make sure that you're really getting a value in TextBox1.Text.
The '' usually means an empty string which, if the TextBox1 was empty, would
look exactly like ''.

When passing dynamic queries, it's often easiest to set the query to a
string variable first so you easily see what you're about to pass to the
database query. Then you could use Trace.Write (or Response.Write for the
more old-fashioned classic asp approach) to see what the actual dynamic
query contains. Checking the query passed helps you from trying to figure
out what's wrong with the query when the query could be fine, it's the data
getting passed into it that's bad or non-existant.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - Expression

"rote" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello Everyone,
> I'm retrieving data from Excel from my asp.net page
> The WorkSheet name is StatusPasPorts.
>
> When i remove the column [Account Reference No.] it does work fine but if
> i use it i get error :
> '' is not a valid name. Make sure that it does not include invalid
> characters or punctuation and that it is not too long.
>
> SELECT [Event Date],[Mobile Number],[Event Type Name],[Identification
> Method],[Customer DOB],[Account Reference No.] FROM [StatusPasPorts$]
> where [Mobile Number] = '" + this.TextBox1.Text.ToString() + "' order by
> [Event Date] ASC
>
> Any ideas what i'm missing.
>
> Thanks in Advance
>
>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
How get all digits, letters and punctuation characters in perl? Peng Yu Perl Misc 2 12-04-2012 09:44 AM
Identifying unicode punctuation characters with Python regex Shiao Python 4 11-19-2008 11:36 AM
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
function that removes the punctuation and some characters like (*&^%$#@!<>?"} from a text string Beznas ASP General 8 09-10-2003 05:34 PM



Advertisments