I have a class that records information on websites that a user visits (URL, Start Time and Ending Time). I then have a sub procedure that inserts this information into database.
The problem I am having is that when I'm building the SQL statement the string variable I am using is not being populated correctly.
When I look at what's in the pstrSQL variable I find this:
INSERT INTO tblWebsites (fldVisitID, fldWebsiteURL, fldWebsiteStartTime, fldWebsiteEndTime) VALUES (100, 'http:\\
This is the error message I get:
Incorrect systax near 'http:\\Unclosed quotation mark before the character string 'http:\\www.google.com'
I think I've narrowed down the problem to the aWebsite.URL statement. If I leave out this property and pass an empty string instead, the SQL statement is built correctly. But when I include the URL, the string doesn't build correctly.
I know I could do this using a stored procedure, but I'm wondering why this simply string concatenation isn't working. I've also tried using a StringBuilder variable as well.
Does anyone know why this could be happening?
-lucyv
The problem I am having is that when I'm building the SQL statement the string variable I am using is not being populated correctly.
Code:
Dim pstrSQL As String
pstrSQL = "INSERT INTO tblWebsites (fldVisitID, fldWebsiteURL, fldWebsiteStartTime, fldWebsiteEndTime) VALUES (" & mlngVisitID & ", '" & aWebsite.URL, & "', '" & aWebsite.StartTime & "', '" & aWebsite.EndTime & "')"
When I look at what's in the pstrSQL variable I find this:
INSERT INTO tblWebsites (fldVisitID, fldWebsiteURL, fldWebsiteStartTime, fldWebsiteEndTime) VALUES (100, 'http:\\
This is the error message I get:
Incorrect systax near 'http:\\Unclosed quotation mark before the character string 'http:\\www.google.com'
I think I've narrowed down the problem to the aWebsite.URL statement. If I leave out this property and pass an empty string instead, the SQL statement is built correctly. But when I include the URL, the string doesn't build correctly.
I know I could do this using a stored procedure, but I'm wondering why this simply string concatenation isn't working. I've also tried using a StringBuilder variable as well.
Does anyone know why this could be happening?
-lucyv