Results 1 to 4 of 4

Thread: sql insert problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    sql insert problem

    Dear All
    I collecting data from an aspx form. my problem is that not all the fields are required and the user may leave them empty.
    then i want to insert values into tPerutim table in SQL server.
    i wrote the folowing sql statement

    Dim ShemPrati, ShemMishpacha As String
    ShemPrati = txtShemPrati.Text

    strSql = "Insert Into tPerutim " & _
    "(Taz, ShemPrati) " & _
    "Values " & _
    "(" & txtTaz.Text & ", " & ShemPrati & ")"

    the problem is that ShemPrati can be empty

    and the statement is collapse
    how can i fix it???

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: sql insert problem

    Either setup the field such that its not required, or use a RequiredFieldNavigator to ensure the user does enter something.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2003
    Posts
    175

    Re: sql insert problem

    first thanks for the reply
    the requiredfieldvalidator here is unacceptable because the field can be empty - its not required.
    any other suggestions???

  4. #4
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Re: sql insert problem

    Before you perform your insert operation just check the textbox for null and if = null insert "".

    Parksie

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