Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDATE TABLE USING ASP

Status
Not open for further replies.

meltingpot

Technical User
May 11, 2004
118
GB
Ive used this code lots but this particular time its got the better of me.

Im updating a field in a table called 'CStatusCode'. Its a text field in Access 2003.Ive cheked that the the data type is right. I get the following page errors

1)
when the "CourseID" has numbers only -

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

2)
when the "CourseID" has numbers and text -
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'CourseID = 5035a'



Code:

Head:
<% If Request.QueryString("update") <> "" Then %>
<%
strConnectionString = "dsn=jsastc"
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.Open strConnectionString
strSQL = "UPDATE Courselist SET Courselist.CStatusCode = '"&(Request.QueryString("update"))&"' WHERE CourseID = "&(Request.QueryString("CourseID"))&""
cnn.Execute strSQL,,adCmdText + adExecuteNoRecords
cnn.Close
%>
<% Else %>
<% End If %>

In Body ...............................
<a href="close_off_course.asp?CourseID=<%=(courselist.Fields.Item("CourseID").Value)%>&update=Finished"><img src="../images/button_fail.gif" width="25" height="20" border="0"></a>

end ----------------------------

I must be making a very basic mistake or ??????

Please help - its driving me MAD !!!!!
 
You're treating the CourseID as a number here
Code:
CourseID = "&(Request.QueryString("CourseID"))&""

Try
Code:
CourseID = '"&(Request.QueryString("CourseID"))&"'"



[sub]____________ signature below ______________
I am Tedward Keyboardhands!!!
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
That worked fantastic - great stuff :)

It was really getting to me...
 
:)


[sub]____________ signature below ______________
I am Tedward Keyboardhands!!!
You are a amateur developer until you realize all your code sucks.
Jeff Atwood[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top