80040e14' (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


prasmile2002 -> 80040e14' (2/28/2005 17:25:20)

Hi

I am using a Form that will take input from users. The query to ad the values to the database is like this:

sSQL = "INSERT into [users_tbl] ([name1], [lname], [mname], [addr], [cit], [sta], [zip], [phone], [phone2], [email], [selectday], [selectmon], [selectyear], [dateapp], [pos], [IP], [res]) values ('" & _
name1 & "', '" & lname & "', '" & mname & "', '" & addr & "', '" & cit& "', '" & sta & "', '" & zip & "', '" & phone & "', '" & phone2 & "','" & email & "', '" & selectday & "', '" & selectmon & "', '" & selectyear & "', '"&Now()&"', '"&pos&"' , '"&IP&"', '" & res & "')"


The res field is a memo field/data type.. When I insert values ..everything works finme..But if the values contain apostrophe (' )
eg: I tried to enter ghfsghdfasghd' "hsdgahs"
.
and it gave me this error

Microsoft JET Database Engine error '80040e14'

Syntax error (missing operator) in query expression ''ghfsghdfasghd' "hsdgahs" . ')'.

Please help...

Thanks
Singh




cliffdeen -> RE: 80040e14' (2/28/2005 19:06:32)

Not sure why you have so many &'s and double quotes, but a normal insert into a sql database is like so:
INSERT INTO USERS_TBL
(NAME1], [MNAME], etc)
VALUES
('::NAME1::', '::MNAME::', etc)

Note: insert names and values MUST match.





Spooky -> RE: 80040e14' (2/28/2005 19:17:42)

Cliff, thats the DRW format, with asp youll use "&" to create your string.

Singh , you need to use a function to replace the quotes.

eg :

Function NoQuote(input)
NoQuote = replace(input,"'","''")
End function

Then use that in your string for each variable:

'" &NoQuote(lname) & "', '" & NoQuote(mname) & "', '" & NoQuote(addr) & "', .....etc





prasmile2002 -> RE: 80040e14' (3/1/2005 14:21:06)

Thanks..that works..

Singh




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625