Results 1 to 10 of 10

Thread: [RESOLVED] inserting into database

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    146

    Resolved [RESOLVED] inserting into database

    i am using a normal inert into statement to insert the data into the access database but theree are some cases in which i need to leave the text box blank then the insert statement gives error can u tell me the method of inserting a blank value that is if the text box has the value that is inserted else blank is inserted
    Using VB.NET 2003/.NET 1.1

    If you found a post useful then please Rate it!
    Please mark you thread resolved using the Thread Tools above

  2. #2
    Addicted Member
    Join Date
    Sep 2006
    Location
    Surabaya, Indonesia
    Posts
    163

    Re: inserting into database

    What error ? AFAIK, textbox will have an empty string if you don't input anything. So, there should be no problem if you leave a textbox empty, unless the field that you want to insert is a primary key.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    146

    Re: inserting into database

    i dont know wats happening but if i leave any of the text box empty then there is an error data type mismatch else it is ok
    Using VB.NET 2003/.NET 1.1

    If you found a post useful then please Rate it!
    Please mark you thread resolved using the Thread Tools above

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    146

    Re: inserting into database

    plz some one help me out
    Using VB.NET 2003/.NET 1.1

    If you found a post useful then please Rate it!
    Please mark you thread resolved using the Thread Tools above

  5. #5
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: inserting into database

    Well that would suggest the fields don't allow Null values, for one. For two, are you opening the connection before sending the data?
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: inserting into database

    If the fields in your access table do not allow null, then you can't insert a null value to it.... So you need to find out the specs for that table, things like field names and data types, allows null or not.... If any field that does not allow null, then you have to supply a default value for that field.

  7. #7
    Junior Member
    Join Date
    Nov 2006
    Posts
    31

    Re: inserting into database

    You could set the value of the textbox to a space (" ") if nothing is input, and this would keep you from having to change the null state on the field, if you are hesitant to do that.

    Hope this helps,
    Brian Swanson

  8. #8
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: inserting into database

    Quote Originally Posted by purpleant
    You could set the value of the textbox to a space (" ") if nothing is input, and this would keep you from having to change the null state on the field, if you are hesitant to do that.

    Hope this helps,
    Brian Swanson
    This works only if that field's data type is string... What if the field is numeric or date?

  9. #9
    Junior Member
    Join Date
    Nov 2006
    Posts
    31

    Re: inserting into database

    I figured it was a safe assumption based on the fact that a textbox was being used and the question being asked that it was a string.

  10. #10
    New Member
    Join Date
    Nov 2006
    Posts
    3

    Re: inserting into database

    Quote Originally Posted by elixir_5000
    i am using a normal inert into statement to insert the data into the access database but theree are some cases in which i need to leave the text box blank then the insert statement gives error can u tell me the method of inserting a blank value that is if the text box has the value that is inserted else blank is inserted

Posting Permissions

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



Click Here to Expand Forum to Full Width