Results 1 to 5 of 5

Thread: Problem related to null value in sql statement

  1. #1
    Join Date
    Aug 2009
    Posts
    63

    Problem related to null value in sql statement

    Hi friends,
    I am getting problem in following SQL statement.
    Code:
     sql = "insert into table2values("& id &"," &_
    	"" & active & "," &_
    	"null," &_
    	"'" & 1stName & "'," &_
    	"'" & 2ndName & "'," &_
    	"'" & 3rdname & "'," &_
                  etc...
    In above query null value shows in red color, it means there is error related to "null" value. Before this error message I have added 2 columns. Can anyone tell me how to fix this problem.
    Thank you.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Problem related to null value in sql statement

    I think there is problem in "null" value, it means error is not connected to that "null" value. I think it might be because you haven't added values for the 2 fields which you are recently added in your insert statement. In this case you have to deleted the columns to fix this problem. After deleting that column you will not get any error.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Problem related to null value in sql statement

    You are getting such type of problem because you haven't declared Field name in your SQL statement. In this case you have to declared Field name in your SQL statement to fix this problem. I have written following SQL query using Field name, just try to use this query in your code to fix this problem.


    Code:
    sql = "insert into table1values (Field1, Field2, Field3, ...) Values ("& ids &"," &_
    	"" & active & "," &_
    	"null," &_
    	"'" & 1stName & "'," &_
    	"'" & 2ndName & "'," &_
    	"'" & 3rdname & "'," &_
                  etc...

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Problem related to null value in sql statement

    When you create new columns you have to define default value other than NULL. Whenever you create the extra columns, you have to tell the database that nulls were acceptable for new fields. In this case you have to tell the database that nulls were acceptable for new fields. Whenever you insert a new record into that table, 2 columns automatically created. You have to remove that 2 fields to fix this problem.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Problem related to null value in sql statement

    You have to Update ALTER TABLE to fix this problem. As per my information it seems that you have use wrong SQL statement for updating table1 and that's why you are getting such type of problem. You have to use following SQL statement in your code to fix this problem.

    sql= "alter table tableA ADD Updated datetime NULL"

    After this you will not get any problem.

Similar Threads

  1. Problem of WHERE clause in SQL statement
    By Macario in forum Software Development
    Replies: 4
    Last Post: 15-10-2010, 08:02 AM
  2. Problem with a null string in java
    By Rily in forum Software Development
    Replies: 4
    Last Post: 12-08-2010, 10:23 AM
  3. SQL statement problem in C#
    By AMISH in forum Software Development
    Replies: 4
    Last Post: 01-06-2010, 01:17 PM
  4. Problem with Prepared statement's 'setDate' method
    By Luis-Fernando in forum Software Development
    Replies: 5
    Last Post: 05-03-2010, 08:19 PM
  5. Problem with if statement in C++
    By Slender in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 09:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,016,863.15319 seconds with 17 queries