Another Go at Null Problem

Results 1 to 3 of 3

Thread: Another Go at Null Problem

  1. #1
    Garnette Lilly Guest

    Default Another Go at Null Problem

    Okay, I muddled this question up so badly before that I&#039;m going to start over. Here goes:<BR>I&#039;m looking for the best solution to deal with a null problem. My ASP pages are connected to an Access 2K backend. My SQL statement displays the record from the database just fine (even those with nulls). After the user edits the record, however, and the following SQL Update statement reads the new data from the form to write back to the database, it hangs on any null entries. <BR><BR>Here is my SQL statement:<BR>Set RS = Conn.execute("UPDATE tblCoHealthDept SET " _<BR>& "HealthDeptName = &#039;" & Request.Form("HealthDeptName") & "&#039;, " _<BR>& "CountyName = &#039;" & Request.Form("CountyName") & "&#039;, " _<BR>& "HDAddress = &#039;" & Request.Form("HDAddress") & "&#039;, " _<BR>& "HDCity = &#039;" & Request.Form("HDCity") & "&#039;, " _<BR>& "HDZip = &#039;" & Request.Form("HDZip") & "&#039;, " _<BR>& "HDEmail = &#039;" & Request.Form("HDEMail") & "&#039;, " _<BR>& "HDEmergPhone = &#039;" & Request.Form("HDEmergPhone") & "&#039;, " _<BR>& "HDFax = &#039;" & Request.Form("HDFax") & "&#039;, " _<BR>& "HDDeliveryAddress = &#039;" & Request.Form("HDDAddress") & "&#039;, " _<BR>& "ChairPhone = &#039;" & Request.Form("ChairPhone") & "&#039;, " _<BR>& "ChairFax = &#039;" & Request.Form("ChairFax") & "&#039;, " _<BR>& "ChairEmail = &#039;" & Request.Form("ChairEMail") & "&#039;, " _<BR>& "ChairDate = &#039;" & Request.Form("ChairDate") & "&#039;, " _<BR>& "HlthOfficerPhone = &#039;" & Request.Form("HlthOffPhone") & "&#039;, " _<BR>& "HlthOfficerFax = &#039;" & Request.Form("HlthOfficerFax") & "&#039;, " _<BR>& "HlthOfficerEMail = &#039;" & Request.Form("HlthOfEMail") & "&#039;, " _<BR>& "HlthOfficerDate = &#039;" & Request.Form("HlthOfDate") & "&#039; " _<BR>& " WHERE tblCoHealthDept.HealthDeptID = &#039;" & HealthDeptID & "&#039; ") <BR><BR>I get a "Type Mismatch" error when I try to run this, and if I remove the fields with null data it runs like a dream. I have searched this site and others and also the MSDN library, but all of the examples I have found deal with running all the fields through a loop with the IsNull function when the fields are written to the page. My field values are not written to the page in a loop. I used Visual Interdev to create the cells in a table, so in the code they are all individually written, like this:<BR><BR>&#060;TD&#062;&#060;INPUT id=text1 name=HealthDeptName VALUE="&#060;% Response.Write RS("HealthDeptName") %&#062;" <BR><BR>Is there a way to deal with nulls in a construction like this? I am totally lost. <BR><BR>Thanks for any help,<BR>Garnette Lilly

  2. #2
    Eddie Campbell Guest

    Default RE: Another Go at Null Problem

    The easiest way is to ensure that none of the form fields passed to the Sql are null.<BR><BR>You can do this by putting a "" on the end of them all like this:<BR><BR>Request.Form("HealthDeptName") & ""<BR><BR>HTH<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Another Go at Null Problem

    Look back to a post on the 21st Titled "For bill Wilkinson".<BR>With some help on a few fine details i have done such a thing.<BR>Alot of code is there and just needs to be played with a bit to meet your sites needs.<BR>To explain in general what i did (might not be quite what you need.)<BR>But, on my site that i administer (A online tourney site)<BR>I have 18 different tables in DB.<BR>I have 2 files that i use as include files at top of page.<BR>File 1 is my Form builder<BR>File 2 is my Table Builder<BR>In File 1- I have made 3 functions<BR>1 function builds a blank form from table query But checking field properties to set up the datatype to be inserted (for valadation later)<BR>2nd function builds all form fields with table field value in them (also checking and identifing field type, size, etc.<BR>then on page i do<BR><BR>Sql "select * from Table1 <BR>open recordset etc here<BR>&#039;call my function<BR>Response.Write RecForm (objRec)<BR><BR>When i post this to either add new record or update record<BR>my 3rd function (validator) weeds out anything with null value<BR><BR>I have really expanded the coding to cover everything...<BR>i can update delete or add new record to any of my db tables.<BR>And all is done using only 2 asp pages and 3 include files...<BR><BR>How many lines of code do i have?<BR>Forms file = 63 lines<BR>tables file = 47 lines<BR><BR>I use these through my whole site.<BR>And withing 1/2 hour i modified it for my other site.<BR><BR>View the codes ( they are only bits & pieces but you will see what gonig on and what to do.)<BR>and probs i can help. But most is there.<BR><BR>Hope it helps<BR>Brian

Posting Permissions

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