Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - desp. updating record prob
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

desp. updating record prob

 Post Reply Post Reply Page  12>
Author
funki View Drop Down
Newbie
Newbie
Avatar

Joined: 06 March 2003
Location: United Kingdom
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote funki Quote  Post ReplyReply Direct Link To This Post Topic: desp. updating record prob
    Posted: 06 March 2003 at 1:08am

I am working on a access Db where I read records from the databse back into a form to update and then resend back to the dbase using update.  I ahve written the following code. Alll that happens is the page does not display.I hoping to seacrh the records set where userId is my link to each record the code is as follows:_

Session("fname") = request("fname")
Session("sname") = Request("sname")
Session("uname") = Request("uname")
Session("pswd") = Request("pswd")
Session("addra") = Request("addra")
Session("addrb") = Request("addrb")
session("county") = Request("county")
Session("postcode") = Request("postcode")
Session("telno") = Request("telno")
Session("fax") = Request("fax")
Session("email") = Request("email")

else


Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
    "DBQ=" & Server.MapPath("db2.mdb") & ";"

sql1 = "Update users Set fname='" & fname & "', sname='" & sname & "' , uname='" & uname & "', pswd='" & pswd & "', addra='" & addra & "', addrb='" & addrb & "', county='" & county & "', postcode='" & postcode & "', telno='" & telno & "', fax='" & fax & "', email='" & email & "', act='" & act & "' Where userID='" & userID& "'"

MyConn.Execute(sql1)

Conn.close
%>

Can some please help me as I am facing a major deadline I have tied several version of updating and none of them seem to work. Hears hoping, any way peace to you all.

Back to Top
Gary View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gary Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2003 at 4:40am

It looks like the values are not being placed in SQL string.
Depending on the form's method (post/get) you should do the following (dont worry about the session stuff).....

Method="Post"
sql1 = "Update users Set fname='" & request.form("fname") & "', sname='" & request.form("sname") and so on......

Method="Get"
sql1 = "Update users Set fname='" & request.querystring("fname") & "', sname='" & request.querystring("sname") and so on......

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2003 at 8:30am
"Request" is generic, it'll pic up either posted data or data on the URL line

but they poster says "page doesn't show"

i dont see any code that shows anything.. that would be one issue...

if there's an error, he doesn't let us know what the error is...

if there is something wrong with the SQL query built, then i bet he didn't Response.Write out the string right before it gets executed to see if the quewry was in fact, correct
Contribute to the working anarchy we fondly call the Internet
Back to Top
funki View Drop Down
Newbie
Newbie
Avatar

Joined: 06 March 2003
Location: United Kingdom
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote funki Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2003 at 10:21am

                    <%

'Collating all the information from the form using the the request command.

fname = TRIM(request("fname"))
sname = TRIM(request("sname"))
uname = TRIM(request("uname"))
pswd = TRIM(request("pswd"))
addra = TRIM(Request("addra"))
addrb = TRIM(Request("addrb"))
county = TRIM(Request("county"))
postcode = TRIM(Request("postcode"))
telno = TRIM(Request("telno"))
fax = TRIM(Request("fax"))
email=Trim(Request("email"))

 

'Error checking of the element thatg make up the form

if fname = "" then

 strError = strError & "Enter your first name.<BR>"
 
end if
if sname = "" then

 strError = strError & "Enter your surname.<BR>"
 
end if
if uname = "" then

 strError = strError & "Enter a user name.<BR>"
 
end if
if pswd = "" then

 strError = strError & "Enter a password .<BR>"
 
end if


if addra = "" then

 strError = strError & "Enter in your address line 1.<BR>"
end if

if addrb = "" then

 strError = strError & "Enter  in your address line 2.<BR>"
end if


if county = "" then

 strError = strError & "Enter  in your City or County.<BR>"
end if

if  postcode="" then
 strError = strError & "Enter your Postcode <BR>"

end if

if telno = "" then

 strError = strError & "Enter  your Telephone<BR>"

end if

if email="" then
strError = strError & " Enter your email<br>"
else
if (instr(1, email,"@")=0) or (instr(1, email, ".")=0) then
strError = strError & " Invalid email<br>"
end if
end if

 

' if there are any error they will be picked up by this next term

if strError <> "" then

%>
                    <!-- Note the error -->
                    <b> There is an error in your registration request: </b> </span>
                  <p> <span class="error">
                    <%

 '  Write out the error messages
 Response.Write strError

%>
                    </span> <br>
                    Click <a href="userupdate.asp" class="purp">here</a>
                    to update.
                    <%

 ' If there are any probelms with form the  information is placed into sessionvariable
 ' for when you are sent back to last page.
 
Session("fname") = request("fname")
Session("sname") = Request("sname")
Session("uname") = Request("uname")
Session("pswd") = Request("pswd")
Session("addra") = Request("addra")
Session("addrb") = Request("addrb")
session("county") = Request("county")
Session("postcode") = Request("postcode")
Session("telno") = Request("telno")
Session("fax") = Request("fax")
Session("email") = Request("email")

else

Session("fname") = request("fname")
Session("sname") = Request("sname")
Session("uname") = Request("uname")
Session("pswd") = Request("pswd")
Session("addra") = Request("addra")
Session("addrb") = Request("addrb")
session("county") = Request("county")
Session("postcode") = Request("postcode")
Session("telno") = Request("telno")
Session("fax") = Request("fax")
Session("email") = Request("email")

else


Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
    "DBQ=" & Server.MapPath("db2.mdb") & ";"

sql1 = "Update users Set fname='" & fname & "', sname='" & sname & "' , uname='" & uname & "', pswd='" & pswd & "', addra='" & addra & "', addrb='" & addrb & "', county='" & county & "', postcode='" & postcode & "', telno='" & telno & "', fax='" & fax & "', email='" & email & "', act='" & act & "' Where userID='" & userID& "'"

MyConn.Execute(sql1)

Conn.close
%>

Here is my sode that is inserted int0 HTML page under neath values are displayed in table,

this is what is displayed on my page instead of table I dont understand where I ahve gone wrong as I can insert and read from same table using same recordset why is now being treated differently

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

/userupdateverification.asp, line 340

Thanks for any help offered. Peace

Back to Top
Gary View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gary Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2003 at 10:38am

It could be the WHERE clause in the SQL.....

What datatype is UserID? If it is integer then lose the single quotes...


& "' Where userID=" & userID

Back to Top
funki View Drop Down
Newbie
Newbie
Avatar

Joined: 06 March 2003
Location: United Kingdom
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote funki Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2003 at 10:55am

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

/userupdateverification.asp, line 340

 

is whgat appears when I take quotes out of code listed above.

When I change the code  & lose single quotes in the version where I use response.form as per you suggestion but when i dothis oages does not appear at all.

eg.

Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
    "DBQ=" & Server.MapPath("db2.mdb") & ";"

sql1 = "Update users Set fname='" & request.form("fname") & "', sname='" & request.form("sname") & "' , uname='" & request.form("uname") & "', pswd='" & request.form("pswd") & "', addra='" & request.form("addra") & "', addrb='" & request.form("addrb") & "', county='" & request.form("county ")& "', postcode='" & request.form("postcode") & "', telno='" & request.form("telno") & "', fax='" & request.form("fax") & "', email='" & request.form("email") & "', act=" & request.form("act") & " Where userID=" & request.form("userID")& ""

MyConn.Execute(sql1)

I'll keep on trying as I have got to getover this hurdle if it kills me.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2003 at 10:59am
instead of guessing, whjy dont you do as suggested above

sql1 = "Update users Set fname='" & request.form("fname") & "', sname='" & request.form("sname") & "' , uname='" & request.form("uname") & "', pswd='" & request.form("pswd") & "', addra='" & request.form("addra") & "', addrb='" & request.form("addrb") & "', county='" & request.form("county ")& "', postcode='" & request.form("postcode") & "', telno='" & request.form("telno") & "', fax='" & request.form("fax") & "', email='" & request.form("email") & "', act=" & request.form("act") & " Where userID=" & request.form("userID")& ""

Response.Write(sql1)
Response.End


MyConn.Execute(sql1)
Contribute to the working anarchy we fondly call the Internet
Back to Top
Gary View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 March 2002
Location: United Kingdom
Status: Offline
Points: 326
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gary Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2003 at 11:02am

As per MorningZ post, i would strongly recommend that you response.write the sql and then .end it

Also, if you could post the table structure (column names & datatypes) it would be helpful.

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.