Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Databases > SQL Development

Sponsored Links

Discuss "special characters" in the SQL Development forum.

SQL Development - Structured Query Language (SQL) is the talk of databases. Discuss topics such as joins, triggers and other advanced SQL topics.


Closed Thread
 
LinkBack Thread Tools Display Modes
  #1  
Old May 21st, 2008, 10:31 AM
Barn Newbie
 
Join Date: Apr 2008
Posts: 21
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 1
Jaykappy is an unknown quantity at this point
Default special characters

I have a few tables in SQL Server, an ODBC link set up on my computer, and an Access Database front end.

In my form I am populating textboxes from another database and a few of the values have Apostrophes in them '.....my SQL INSERT INTO statement is not working on the records that have Apostrophes...

The fields in the SQL database are text fields....Is there anything that I can do to get the SQL update to work? Syntax wise?

Of do I have to go through an remove the Apostrophes' and periods . etc

THis is an example of the textbox value:
Kingston's Meadow

This is the code I am using...

THANKS


Code:
varName = Text82
varOwners_Residence = Text84
varNotice_Expiration = cbo_94
varNotes = Text104
varNotice_Number = Text80
varStatus = Text88
'varResides = ""
'varturn_in = ""
varNotice_Date = cbo_92
varProperty_Address = Text86
varNuisance_Type = Combo98
varAddition_Name = Addition_Name
varRange = Range
varLot = Lot
varBlock = Block
varZip_Code = Zip_Code
varDisplay_PID = PID
varSec_tion = Sec_tion
varTownship = Township
varProperty_City = Text106
varProperty_State = Text108
varProperty_Zip = Text110

varPictureID = Text160
varPicturePath = "\\weeds_database\Weeds_Database_Images\"

varOwner_City = Text194
varOwner_State = Combo202
varOwner_Zip = Text196


Dim varID As Integer
varID = Val(DMax("ID", "dbo_data")) + 1
'MsgBox varID

'===============================================
'===============================================

Dim MySQL As String

MySQL = ""

'MySQL = "INSERT INTO tbl_TRAINING (VendorNumber, FirstName, LastName, Dates, TimeLength, Type, Hours, Experienced_Judge, Attended) values ('" & varVendorNumber & "', '" & varFirstName & "', '" & varLastName & "', '" & varDates & "', '" & varTime & "', '" & varType & "', '" & varHours & "', '" & varExperiencedCheck & "','" & varAttendedCheck & "');"
MySQL = "INSERT INTO dbo_data ("
MySQL = MySQL & "ID,Name,Owners_Residence,Notice_Expiration,Notes,Notice_Number,Status,Notice_Date,Property_Address,Nuisance_Type,Addition_Name,Range,Lot,Block,Zip_Code,Display_PID,Sec_tion,Township,Property_City,Property_State,Property_Zip,PictureID,PicturePath,Owner_City,Owner_State,Owner_Zip"
MySQL = MySQL & ") values ("
MySQL = MySQL & "'" & varID & "','" & varName & "','" & varOwners_Residence & "','" & varNotice_Expiration & "','" & varNotes & "','" & varNotice_Number & "','" & varStatus & "','" & varNotice_Date & "','" & varProperty_Address & "','" & varNuisance_Type & "','" & varAddition_Name & "','" & varRange & "','" & varLot & "','" & varBlock & "','" & varProperty_Zip & "','" & varDisplay_PID & "','" & varSec_tion & "','" & varTownship & "','" & varProperty_City & "','" & varProperty_State & "','" & varZip_Code & "','" & varPictureID & "','" & UpdateFullPath & "','" & varOwner_City & "','" & varOwner_State & "','" & varOwner_Zip & "'"
MySQL = MySQL & ");"

DoCmd.SetWarnings False
'MsgBox MySQL
DoCmd.RunSQL MySQL
Sponsored Links
  #2  
Old May 21st, 2008, 10:50 AM
Barn Newbie
 
Join Date: Apr 2008
Posts: 21
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 1
Jaykappy is an unknown quantity at this point
Default

Got it...from another forum......just did this on each variable....

varName = Replace(Text82,"'","''")
Closed Thread

  DeveloperBarn Forums > Databases > SQL Development

Bookmarks

Thread Tools
Display Modes

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 On

Forum Jump


All times are GMT -4. The time now is 10:59 PM.



Content Relevant URLs by vBSEO 3.2.0