Updating string and number formats??

Results 1 to 2 of 2

Thread: Updating string and number formats??

  1. #1
    Big Mac Guest

    Default Updating string and number formats??

    Hi,<BR><BR>I have a field in Access called "ID" and it is defined as a number. <BR>In my ASP page I have :<BR>&#062; response.write "&#060;input type=""text"" length=""5"" name=""txtRC"" value=""" & objRS.fields("ID") & """&#062;"<BR><BR>If I update that field and write it back to Access, does "ID" become a string and I have to convert it to a number before updating the DB?? Same question for a date field.<BR><BR>Thanks in advance.

  2. #2
    Neil Popham Guest

    Default RE: Updating string and number formats??

    it purely depends on your method and/or SQL string<BR><BR>if you are using an &#039UPDATE&#039 SQL statement then it obviously depends on the format, ie: if you are setting a number DON&#039T enclose the value in apostrophes, eg:<BR><BR>...SET ID=" & intID & ", ...<BR><BR>if you are using the &#039open recordset&#039 method then it may be EVEN MORE prudent to do some checks on the form return, AND convert the value, before inserting. eg:<BR><BR>&#062; intID = Request.Form("ID")<BR>&#062; If Not IsNumeric(intID) Then Response.Redirect "error.htm"<BR>&#062; If intID &#062; 32767 Then Response.Redirect "error.htm"<BR>&#062; intID=CInt(intID)<BR>&#062; ...<BR>&#062; objRec("ID") = intID<BR><BR>obviously the checks should still be performed before either method, but the SQL method does not care what format the number is in (string or numeric) as it is being passed in a string anyway.<BR><BR>hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts