|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
How do i get rid of the apostrophe in the query expression, "Kuai Junyi' Jayvis')'??
selectStudInfo = "SELECT `QUERY$`.`Acad Prog`, `QUERY$`.ID, `QUERY$`.Name FROM `D:\pd2\Q181_20`.`QUERY$` `QUERY$`" rs.Open selectStudInfo, cn, adOpenDynamic Insert = "Insert into studinfo values('" & PROG & "','" & STUD_ID & "','" & STUD_NAME & "')" I have attached a file for ref of my error. Last edited by nicjuan : March 8th, 2004 at 09:35 PM. Reason: Missing Attachment |
|
#2
|
||||
|
||||
|
To insert text with (') apostrophes in it, you need to double them (they are escape characters) you can do this.
Code:
Insert = "Insert into studinfo values('" & ReplaceQuotes(PROG) & "','" & ReplaceQuotes(STUD_ID) & "','" & ReplaceQuotes(STUD_NAME) & "')"
Public Function ReplaceQuotes(strValue As String) As String
Dim strNewValue As String
strNewValue = Replace(strValue, "'", "''")
ReplaceQuotes = strNewValue
End Function
Just an observation. If a variable ends with ID is should probably be a number, not text. If STUD_ID is a number, it doesn't need (') single quotes around it. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Apostrophe causing syntax error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|