Forums
This topic is locked
select where numeric field
12 May 2007 18:41:15 Joan Ward posted:
I have inherited a website script that provides admin functionality allows to edit record details that are displayed on the site. The admin page brings back a list of property records and when you click on the Edit link next to a specific property it opens an edit.asp page which shows all the fields for updating that relate to that specific property record. At the moment the "Ref" field which defines the recordID is a text field and contains an alphanumeric value that is assigned manually when the record is added. We need to change the database so that the "Ref" value is assigned automatically as a number (ie. autonumber as the field type). However when I change the field type to autonumber in the database this causes and error when edit.asp script runs - the error is defined as a data type mismatch. I presume therefore that where the "Ref" value is included in the edit.asp script it needs to be changed to accommodate the fact that the "Ref" field type is now numeric not text. The relevant part of the existing edit.asp script is as follows, can anyone advise how this needs to be amended please.<%
session("oldref"=request("ref"
ref=""
heading=""
inputdate=""
details=""
askprice=0
PDFpresent=0
if request("ref"<>"" then
Set DataConn = Server.CreateObject("ADODB.Connection"
DataConn.Open "dbconnection" 'Open connection
Query="SELECT * FROM property WHERE ref='" & request("ref" & "';"
Set RSlist = Server.CreateObject("ADODB.RecordSet"
RSlist.Open Query,DataConn,3
ref=rslist("ref"
heading=rslist("heading"
inputdate=rslist("inputdate"
details=rslist("details"
askprice=rslist("askingprice"
PDFpresent=rslist("PDFpresent"
next
end if
%>
Replies
Replied 16 May 2007 21:26:56
16 May 2007 21:26:56 dave blohm replied:
i'm assuming that you are using Access...
The autonumber data type in Access is the same as an Identity Integer field in SQL. The short and long of it is that a field of the interger data type, as the name would suggest, accomdates integers. Setting it to Identity means that it will auto increment and has to be unique.
Your problem is that heretofore your REF field has been filled with data of some variation of a text data type. When you attempt to convert the field to the Autonumber data type it fails because the existing data is non-integer.
Unfortunately, there is no quick fix. If you want to change the REF field to Autonumber you will not be able to use the existing record IDs.
- Doc
Progress is made by the discontent.
The autonumber data type in Access is the same as an Identity Integer field in SQL. The short and long of it is that a field of the interger data type, as the name would suggest, accomdates integers. Setting it to Identity means that it will auto increment and has to be unique.
Your problem is that heretofore your REF field has been filled with data of some variation of a text data type. When you attempt to convert the field to the Autonumber data type it fails because the existing data is non-integer.
Unfortunately, there is no quick fix. If you want to change the REF field to Autonumber you will not be able to use the existing record IDs.
- Doc
Progress is made by the discontent.