Forum Moderators: open

Message Too Old, No Replies

help with ASP database

forms and updating records

         

nym_fan

4:34 am on Oct 7, 2001 (gmt 0)

10+ Year Member



I am working on an ASP script to update a record in an Access database. Everything is working except the statement which tells the scirpt which record to update. I get an "operator missing' error. If I take out the offending line, all records in the database are updated, so I know (or think) that everything else is ok.
If anyone has some knowledge of the subject and is willing to help, I would appreciate it.

sugarkane

10:45 am on Oct 7, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi nym_fan,

If you could post a small snippet of the script and point out the offending line, I'm sure someone will be able to spot the error.

At first glance, 'operator missing' sounds as if it's a problem with the ASP syntax rather than the database interaction as such.

nym_fan

6:26 pm on Oct 7, 2001 (gmt 0)

10+ Year Member



Here is what I have:
strDBPath ="D:\..........link1.mdb"

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & strdbpath
RS=Server.CreateObject("ADODB.RecordSet")

sqlstmt =vbNullString
SQLStmt = sqlstmt & "UPDATE linksdata "
SQLStmt = SQLStmt & "SET linkurl= '" & edLink1 & "' "
sqlstmt = sqlstmt & ", Title='" & edtitle & "' "
......
SQLStmt = SQLStmt & ", Adddate='" & edate & " '"
---->SQLStmt = SQLStmt & "Where Linknum="& request("item")&""

response.write SQLstmt

Conn.Execute(SQLStmt)

the line with the arrow is where the problem lies. I am trying to have it change the record which has the linknum which is sent with the form. Make sense?

Thanks

evinrude

9:12 pm on Oct 7, 2001 (gmt 0)

10+ Year Member



My first (quick) guess would be that the missing space between the final two statements might prove problematic. If you look that the output of your response.write sqlstmt you'll notice it's missing.

added... - Also, not sure why you have the final & "", since all that's doing is adding ...errr... nothing to the end of the string.

evinrude

9:50 pm on Oct 7, 2001 (gmt 0)

10+ Year Member



Hmmm...not sure how much comfort this will provide, but I threw together a test database in access and copied your code, and everything seemed to work just peachy. :) Even without the space between sections.

My guess, then would be that perhaps the data expected is not getting passed. For example, I can bring up the error "missing operator" by not including the expected request("item"). Since all you have is request("item") I can't be sure if it's expecting the data via the post or get method. If the data is expected in the URL (the get method), check to see if your URL is passing this info (for example webpage.asp?item=1234). If it's passed from a form using the post method, go back to originating page and make sure the name of the field is the same as the request on the expecting page.

Hope that helps. :)

nym_fan

3:34 am on Oct 8, 2001 (gmt 0)

10+ Year Member



Thanks for the info.It is still not working. I am moving the info via a url, and I have the "get" method implemented.
I am using a form to update my links and a submit button. When it gets to the edit page it has the item=# in the url correctly but when it goes to the page to process the info, it shows www......item=(all the info I am processing) does that make sense? Could I send you my files evinrude or would you be willing to go to my test pages and take a look?

Xoc

6:43 am on Oct 8, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Insert a space before the "Where". Remove the & "" at the end. Like this:

SQLStmt = SQLStmt & " Where Linknum=" & request("item")

That & "" is a trick that converts numbers and nulls to strings, but you don't need to do that here, since request is always going to return a string.

[aside: the expression 6 & "" returns "6". null & "" returns "". "foo" & "" returns "foo". It's a handy way to convert things to strings. I actually think null & "" should have returned null, but it's now a documented bug that it returns "".]

nym_fan

3:30 am on Oct 11, 2001 (gmt 0)

10+ Year Member



thanks everyone for your input.

FYI-it was an issue with using the "get" vs "post" method to send information.
All fixed now