Hello!
Why when I try to save a null value from textbox at sql server 0 is saved?
The field type is number.
I use an insert query to do that
thanx in advance

You won't be able to insert an actual NULL/Nothing into the database.
You will need to use either the word " NULL " in your SQL or use DBNull.Value in your parameters (if you're using a parameterized query).

As it is a number datatype a null value wont be stored in the column....it will store 0 as null value....

change it to text and then u can save a null value....

commented: Good catch! +12

Try this :

Dim sql As String 
  If TextBox1.Text.Length <> 0 Then
            str = "'" & TextBox1.Text & "'"
        Else
            str = "NULL"
  End If

  sql = "insert into test(test1) values(" & str & ")"
  dp.save_sql(sql) 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.