Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL Syntax
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL Syntax

 Post Reply Post Reply
Author
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Topic: SQL Syntax
    Posted: 25 September 2003 at 7:59pm

Having some troubles and wandering if someone could point me in the right direction.  I can trying to update a row with values from a form

The problem is I want the value of strXXXX and not the string "strXXX"

strFirstName = Request.Form("txtFirstName")
strLastName = Request.Form("txtLastName")
strHomepage = Request.Form("txtHomepage")
strAim = Request.Form("txtAim")
strLocation = Request.Form("txtLocation")
strInterests = Request.Form("txInterests")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "UPDATE firstname, lastname VALUES ('strFirstName', 'strLastName') WHERE ID =" & userID

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Posted: 25 September 2003 at 9:55pm

You aren't using the UPDATE statement right, check here: http://www.w3schools.com/sql/sql_update.asp

Back to Top
3BEPb View Drop Down
Groupie
Groupie


Joined: 07 August 2003
Location: United States
Status: Offline
Points: 81
Post Options Post Options   Thanks (0) Thanks(0)   Quote 3BEPb Quote  Post ReplyReply Direct Link To This Post Posted: 26 September 2003 at 12:00am
strSQL = "UPDATE table_name set table_name.firstname='strFirstName', table_name.lastname'strLastName') WHERE ID =" & userID
Back to Top
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Posted: 26 September 2003 at 9:12am

I am still having troubles.  When I hit enter on my form this is what I get

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.

/updateprofile.asp, line 37

 

 

Code: - Line 37 is marked below

<%
Dim strUserName 'Holds the name of the user
Dim userID
Dim adoCon         'Holds the Database Connection Object
Dim rsViewProfile   'Holds the recordset for the records in the database
Dim strSQL          'Holds the SQL query to query the database

'Get the users name passed from the previous page
strUserName = Session("userName")

userID = Session("userID")


'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("toddwoolums_site.mdb")

strFirstName = Request.Form("txtFirstName")
strLastName = Request.Form("txtLastName")
strHomepage = Request.Form("txtHomepage")
strAim = Request.Form("txtAim")
strLocation = Request.Form("txtLocation")
strInterests = Request.Form("txInterests")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "UPDATE tblUsers SET tblUsers.firstname='strFirstName', tblUsers.lastname='strLastName', tblUsers.homepage='strHomepage', tblUsers.aim='strAim', tblUsers.location='strLocation', tblUsers.interests='strInterests' WHERE ID =" & userID

'Open the recordset with the SQL query
Set rsEditProfile = adoCon.Execute(strSQL) --Line 37

'Reset server objects
rsEditProfile.Close
Set rsEditProfile = Nothing
Set adoCon = Nothing
%>



Edited by twooly
Back to Top
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Posted: 26 September 2003 at 9:58am

OK I got the other error fixed. I didn't have the correct permissions on the database.  Now I am getting this

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

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ID ='.

/updateprofile.asp, line 37

Back to Top
twooly View Drop Down
Groupie
Groupie


Joined: 24 September 2003
Status: Offline
Points: 64
Post Options Post Options   Thanks (0) Thanks(0)   Quote twooly Quote  Post ReplyReply Direct Link To This Post Posted: 26 September 2003 at 10:02am

Yet again I found out what that error was.  My session variable needed to me passed to the next page.  It almost works the way I want it too.  The only problem now is that it passes "strFirstName" and not the actual value of the variable.  How can I get it to update with the variable value.

 

Code

<%
Dim strUserName 'Holds the name of the user
Dim userID
Dim adoCon         'Holds the Database Connection Object
Dim rsViewProfile   'Holds the recordset for the records in the database
Dim strSQL          'Holds the SQL query to query the database

'Get the users name passed from the previous page
strUserName = Session("userName")

userID = Session("userID")


'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("toddwoolums_site.mdb")

'Create an ADO recordset object
'Set rsEditProfile = Server.CreateObject("ADODB.Recordset")

 

strFirstName = Request.Form("txtFirstName")
strLastName = Request.Form("txtLastName")
strHomepage = Request.Form("txtHomepage")
strAim = Request.Form("txtAim")
strLocation = Request.Form("txtLocation")
strInterests = Request.Form("txInterests")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "UPDATE tblUsers SET tblUsers.firstname='strFirstName', tblUsers.lastname='strLastName', tblUsers.homepage='strHomepage', tblUsers.aim='strAim', tblUsers.location='strLocation', tblUsers.interests='strInterests' WHERE ID =" & userID

'Open the recordset with the SQL query
'rsEditProfile.Open strSQL, adoCon
Set rsEditProfile = adoCon.Execute(strSQL)

'Reset server objects

Set rsEditProfile = Nothing
Set adoCon = Nothing
%>

Back to Top
KCWebMonkey View Drop Down
Senior Member
Senior Member
Avatar
Go Chiefs!

Joined: 21 June 2002
Status: Offline
Points: 1319
Post Options Post Options   Thanks (0) Thanks(0)   Quote KCWebMonkey Quote  Post ReplyReply Direct Link To This Post Posted: 26 September 2003 at 10:21am
strSQL = "UPDATE tblUsers SET tblUsers.firstname='" & strFirstName & "', tblUsers.lastname='" & strLastName & "', tblUsers.homepage='" & strHomepage & "', tblUsers.aim='" & strAim & "', tblUsers.location='" & strLocation & "', tblUsers.interests='" & strInterests & "' WHERE ID =" & userID
Back to Top
 Post Reply Post Reply

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.