Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Inputting single code string data

Author  Topic 

pwint
Starting Member

7 Posts

Posted - 2005-08-22 : 12:21:15
Hi
I have a problem in inputing single code(') string into the SQL database. I wrote in ASP language and connect to the SQL server to insert the data.
If the data contains single code string (e.g women's group)the syntax error appears and it stops.
I tried to change the double code(")instead of single one to insert the data and then, it also has error "does not permit column name ...." or something like that.
How can i solve the problem to input the data that contains single code(')?
Any help appreciated. Thanks.

Thrasymachus
Constraint Violating Yak Guru

483 Posts

Posted - 2005-08-22 : 13:53:45
this has always worked for

in your vb...

sql = "EXEC dbo.MyStoredProcedure @param = REPLACE(data,"'","''")"
rs.Open sql, con

====================================================
Regards,
Sean Roussy

Thank you, drive through
Go to Top of Page

pwint
Starting Member

7 Posts

Posted - 2005-08-22 : 22:29:10
Here is my coding in ASP. In there i tried to change the code from
'" & xxx & "' to """ & xxx & """. But it doesn't work. How can i fix the problem?Is there any setting need to adjust in SQL for double code?

SQLstmt2 = "INSERT INTO pmfOrganization (IndicatorNo,IndRefNo,OrgPrjName,ContactPerson,Address1,Address2,Telephone,Fax,Mobile,Email,Website,Description,City,Country)"
SQLstmt2 = SQLstmt2 & " VALUES ('" & cData & "','" & sIdRef & "',
""" & cOrgName & """,""" & cPerson & """, """ & cAddress1 & """,
""" & cAddress2 & ""","'" & nPhone & "','" & nFax & "','" & nMobile & "','" & cEmail & "','" & cWebsite & "',""" & cDescription & """,
"'" & cCity & "','" & cCountry & "')"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-23 : 01:18:17
For numeric data types use " & var & "
and for strings use '" & var & "'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -