a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

stuborn sql update statement

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> stuborn sql update statement
Page: [1]
 
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
stuborn sql update statement - 5/15/2006 15:13:08   
Can someone please look over this and see if you see anything wrong. It goes through without a problem but doesnt actually change anything in the database. I am trying to update multiple records at once. The user changes the "numorder" of the items by typing in a number into the "<% =FP_FieldVal(fp_rs,"ID") %>numorder" field in my form and then submits to the
page which contains the following code. Any Ideas on

1) what it is doing.
and
2) how to get it to do what i want it to do.



set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "d:\hosting\washurjosh\fpdb\technicalupdateresume.mdb"
set rs=Server.CreateObject("ADODB.recordset")



Dim MyString, MyArray
MyString = Request.Form("ID")
MyArray = Split(MyString,",")
For i=0 to UBound(MyArray)
SQL = "Update Results Set numorder=" & MyArray(i) & Request.Form("numorder") & " WHERE ID=" & MyArray(i) 
rs.Open SQL, conn 
Next  
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: stuborn sql update statement - 5/15/2006 15:29:54   
quote:

... & MyArray(i) & Request.Form("numorder") & ...


I think you may be trying to do this?

... & Request.Form(MyArray(i) &"numorder") & ...

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to washurjosh)
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
RE: stuborn sql update statement - 5/15/2006 15:34:55   
yes that is what im trying to do, i tried it your way and go this error


Microsoft JET Database Engine error '80040e14'
Syntax error in UPDATE statement.

/techupdateorderdo.asp, line 187


and line 186 and 187 is:

186: SQL = "Update Results Set numorder=" & Request.Form(MyArray(i) & "numorder") & " WHERE ID=" & MyArray(i)

187: rs.Open SQL, conn

(in reply to rdouglass)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: stuborn sql update statement - 5/15/2006 15:54:23   
quote:

186: SQL = "Update Results Set numorder=" & Request.Form(MyArray(i) & "numorder") & " WHERE ID=" & MyArray(i)

187: rs.Open SQL, conn


Try this to see what we get for SQL:

....
SQL = "Update Results Set numorder=" & Request.Form(MyArray(i) & "numorder") & " WHERE ID=" & MyArray(i)

Response.write(SQL)
Response.end


rs.Open SQL, conn
....

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to washurjosh)
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
RE: stuborn sql update statement - 5/15/2006 16:10:16   
it goes through but doesnt show me the sql or an error

(in reply to rdouglass)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: stuborn sql update statement - 5/15/2006 16:14:05   
quote:

it goes through but doesnt show me the sql or an error


Are you sure it 'goes thru'? That code is intended to stop all page operations when it gets to that point.

Have you tried to View Source to see if the query is in there? Depending where it actually is on the page can influence whether it is visible or not but should always be in View Source.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to washurjosh)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: stuborn sql update statement - 5/15/2006 16:15:40   
quote:

SQL = "Update Results Set numorder=" & Request.Form(MyArray(i) & "numorder") & " WHERE ID=" & MyArray(i)


Also, is numorder a number field? As your query stands, it is sending the data as if it were a number and not text.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to rdouglass)
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
RE: stuborn sql update statement - 5/15/2006 16:47:59   
ok so i changed my field to number type in access and i see the sql IS being displayed on the page

this is what i get

Update Results Set numorder=10 WHERE ID=10

(in reply to rdouglass)
washurjosh

 

Posts: 66
Joined: 1/18/2006
Status: offline

 
RE: stuborn sql update statement - 5/15/2006 18:04:57   
fixed it. Took me a while to figure it all out in my brain what it needed to do.

this is the finished code.


<%

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "d:\hosting\washurjosh\fpdb\technicalupdateresume.mdb"
set rs=Server.CreateObject("ADODB.recordset")



Dim MyString, MyArray, MyNewArray
MyString = Request.Form("ID")
MyArray = Replace(Mystring," ","")
MyNewArray = Split(MyArray,",")

For i=0 to UBound(MyNewArray)
Dim thefieldname, thefieldvalue
thefieldname = MyNewArray(i) & "numorder"
thefieldvalue = Request.Form(thefieldname)

SQL = "Update Results SET numorder=" & thefieldvalue & " WHERE ID=" & MyNewArray(i) 

rs.Open SQL, conn 
Next  

%>

(in reply to washurjosh)
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> ASP and Database >> stuborn sql update statement
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts