Problem inserting null values from ASP page

Results 1 to 2 of 2

Thread: Problem inserting null values from ASP page

  1. #1
    Join Date
    Dec 1969

    Default Problem inserting null values from ASP page

    Hello,<BR><BR>I have this sql table MM_MASTER WITH FIELDS MM_ID INT IDENTITY, MM_NO INT,MM_PH INT,MM_REMARKS VARCHAR(20).<BR><BR>I am trying to insert values into this table from my asp page.<BR><BR>for all the fields allow null is set in the SQL server table.<BR><BR>MM_NO=request("MM_NO")<BR>MM_PH=requ est("MM_PH")<BR>MM_REMARKS=request("MM_REMARKS")<B R><BR>sqlins="insert into MM_MASTER VALUES("&MM_N0&","&MM_PH&",&#039;"&MM_REMARKS&"&#0 39;)"<BR>ObjDBConn.sqlins(sqlins)<BR><BR>I am getting error near , when I try to do response.write<BR>I am able to see this insert into MM_MASTER(,222222,&#039;remakrs ok&#039;)<BR><BR>After doing this I added this line in the code<BR>if MM_NO="" then MM_NO=Null<BR><BR>even after adding this I am still getting the above said error.<BR><BR>Please help

  2. #2
    Join Date
    Dec 1969

    Default RE: Problem inserting null values from ASP page

    Look at your SQL query:<BR>[code language="T-SQL"] insert into MM_MASTER(,222222,&#039;remakrs ok&#039;)[/code]<BR><BR>Look between "MM_MASTER(" and "222222". You&#039;ve got a comma. Which means SQL Server is expecting a value. You can&#039;t just leave the value out and expect it to assume null. Or default. Or whatever.<BR><BR>The problem&#039;s compounded by the fact that you don&#039;t specify which columns you&#039;re inserting into, so SQL Server has to make assumptions.<BR><BR>Open Books Online. Go to "Index". Type in "null values" and then choose "explicit" underneath that. There&#039;s a good example of how to explicitly and implicitly insert null values through SQL.<BR><BR>Then try and modify your SQL query accordingly.<BR><BR>Craig.

Posting Permissions

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