| Author |
Topic  |
|
|
AskSQLTeam
Ask SQLTeam Question
USA
0 Posts |
|
|
RocketScientist
Official SQLTeam Chef
USA
85 Posts |
|
|
Anonymous
Starting Member
0 Posts |
Posted - 04/04/2001 : 09:23:38
|
| Apostrophe Problem PLEASE HELP! I can't figure out exactly how to use your VB apostrophe fix. I keep getting this error: Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''Jill O'Reilly','VISN3's Webmaster''. /BegASPdatabases/chapter.10/nceconsult2.asp, line 314 (line 314 is the objCmd.Execute command!!!)
What am I doing wrong in my HTML page below):
<% 'Declare variables needed Dim strInsert Dim strValues Dim adCmdText
'Set required variables adCmdText = 1
'*********************************************************** '* If an Add was requested, add the new consult to the database '***********************************************************
'change apostrophes to quote marks in text fields Requestor_Name = replace (Requestor_Name,"'","''") Requestor_Title = replace (Requestor_Title,"'","''")
If Request.Form("Action") = "Add" Then
'Start building the SQL strings with the required fields strInsert = "Insert into NCEConsult (Requestor_Name,Requestor_Tel" strValues = "Values('" & CStr(Request.Form("txtRequestorName")) & _ "','" & CStr(Request.Form("txtRequestorTel")) & "'" 'Add contact method if present If Len(Request.Form("txtContactMethod")) > 0 Then 'Add the column name to the insert string strInsert = strInsert & ",Contact_Method" 'Add the value to the value string strValues = strValues & ",'" & _ Cstr(Request.Form("txtContactMethod")) & "'" End If 'Add requestor title if present If Len(Request.Form("txtRequestorTitle")) > 0 Then 'Add the column name to the insert string strInsert = strInsert & ",Requestor_Title" 'Add the value to the value string strValues = strValues & ",'" & _ Cstr(Request.Form("txtRequestorTitle")) & "'" End If
'Add requestor address if present If Len(Request.Form("txtRequestorAddress")) > 0 Then 'Add the column name to the insert string strIns |
 |
|
|
Sameal
Starting Member
USA
1 Posts |
Posted - 08/05/2001 : 18:49:56
|
After spending six hours today pulling my hair out over this little apostrophe problem, you all fix me up in 1 minute or less. Thanks.
Robert Padgett rob@lorwayco.com Precision Machining Services. Inc. |
 |
|
|
wevans
Starting Member
1 Posts |
Posted - 11/25/2002 : 01:26:00
|
I actually think the best way on both inserts and subsequent queries against the data is to use Chr(146).
Something like this:
Replace(Request.Form("DaInBox"),"'",Chr(146))
|
 |
|
|
sqlMichael
Starting Member
Canada
1 Posts |
Posted - 10/23/2009 : 17:44:32
|
I've creaetd a sProc that uses the QUOTENAME function, it runs fine in SQL Server 2005, but when I add the sProc to a reporting service, the output file now has triple the amount of quotes I was expecting. EXMAMPLE: Query returns "NAME" Using a subscription service, the output is now """NAME""" I've setup the subscription to output with as a comma delimited CSV file.
Query is setup as Select 'Client Name' = QUOTENAME(CLNAME,'"') From TABLE
Is the triple quotes a result of the use of QUOTENAME, or a result of the reporting service? Sorry if this topic should be posted under a differnt area. It's my first post.
sglmichael |
 |
|
| |
Topic  |
|
|
|