Syntax Error when connecting to SQL database

B

bravesplace

I am connecting to an SQL database and one of the fields is named
"Case#".

I am getting syntax errors trying to connect, and am pretty sure it is
because of the special character in the name (#).

Is there anything I can do to get around this without having them
change the name and remove the special character?

This is the line I think the problem exists:

fp_sQry="SELECT * FROM ""Returns Info"" WHERE (Case# = ::Case#::)"
 
R

Ronx

Try
fp_sQry="SELECT * FROM [Returns Info] WHERE ([Case#] = ::Case#::)"

Your fieldname Case# may also be a problem, since the # terminates a
querystring in a URL if using GET, not sure how POST treats it.
 
S

Stefan B Rusynko

Case is a reserved word

Change your DB field name to say CaseNo
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I am connecting to an SQL database and one of the fields is named
| "Case#".
|
| I am getting syntax errors trying to connect, and am pretty sure it is
| because of the special character in the name (#).
|
| Is there anything I can do to get around this without having them
| change the name and remove the special character?
|
| This is the line I think the problem exists:
|
| fp_sQry="SELECT * FROM ""Returns Info"" WHERE (Case# = ::Case#::)"
|
 
K

Kevin Spencer

Assumning the database is Access or SQL Server, you can also enclose
database object names (such as table and column names) in [square brackets]
to indicate that they are object names, and not reserved words, or if the
database object names have spaces or other illegal characters in them.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

What You Seek Is What You Get.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top