Insert Into Error

Results 1 to 3 of 3

Thread: Insert Into Error

  1. #1
    Join Date
    Dec 1969

    Default Insert Into Error

    Hello:<BR>My insert statement is below<BR><BR>cmd.CommandText = "INSERT INTO list (lastname, firstname, homenumber, worknumber, cellphone, email, address, city, state, zip, birthday, info) VALUES (&#039;" & strlastname & "&#039;, &#039;" & strfirstname & "&#039;, &#039;" & strhomenumber & "&#039;, &#039;" & strworknumber & "&#039;, &#039;" & strcellphone & "&#039;, &#039;" & stremail & "&#039;, &#039;" & straddress & "&#039;, &#039;" & strcity & "&#039;, &#039;" & strstate & "&#039;, &#039;" & strzip & "&#039;, &#039;" & strbirthday & "&#039;, &#039;" & strinfo & "&#039;);" <BR><BR>I know the problem is in the strbirthday at the end of the statement. Everything was working fine until I added it. In the database I have it as a non required field. When put all of the information in that page that has this statement in it, it&#039;s fine. If I put all of the information, excluding the birthday, it errors out and says there is a data type mismatch. How do I get it to accept the null value. Also, it is a date/time field in my database if that makes a difference.<BR>Any help is greatly appreciate<BR>Thanks<BR>Scott

  2. #2
    London Guest

    Default RE: Insert Into Error

    You&#039;re passing it &#039;NULL&#039; value, just like that, with the quotes. It tries to convert it to date and is failing. Check for valid date first before inserting into the database.<BR><BR>Hope this helps.

  3. #3
    Join Date
    Dec 1969

    Default RE: Insert Into Error

    what kind of database do you have? Could you set a default for that field? Firstly you say that everything was working fine until you put the birthday column in, and then later you say that when you put everything in, excluding the birthday, you get a data type mismatch. Do you mean including the birthday? You can default the date/time field to any date/time. You may also try to put "on error resume next" before the cmd.CommandText.<BR>Good luck!

Posting Permissions

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