Dear Friendz
Ihave face problem with null value i remove the chk from null value n sql server and when i direct save anything in table it dosen't accept null value but when i save these in my form it accept null value . i don't know why form do these plz help me about these problem

Changing the allow null in sql is not automatically picked up by VS designers.
You need to manually change the AllowDBNull property of each column in your tables.
You can do this in the dataset designer.

Edited 6 Years Ago by nick.crane: n/a

Assuming that you created a DataSet using the Visual Studio designer and dragged a table from your DB on to the design surface the table will have been created using the values from the DB at that time. Any changes to the DB are not automatically updated in the dataset unless you re-create the dataset.

To change the AllowDBNull property of a column:
Open your dataset in the DataSet designer.
Click on the column in the table you wish to modify.
This will display the column properties in properties window.
Scroll the propeties window to find AllowDBNull and change it.

Edited 6 Years Ago by nick.crane: n/a

i am not using the datset tool
i am using it through coding

DIM DS as new dataset

So plz guide me to set allowdbnull property through coding

AllowDBNull is a property on the data columns.
Show me the code where you create the dataset and I'll try to help.

Dim Con As New SqlConnection
Dim Da As New SqlDataAdapter
Dim Ds As New DataSet
Dim Sql As String

AND FOR SAVE

Dim counter, abc As Integer
counter = DataGridView1.Rows.Count - 1
MsgBox(counter)
For abc = 0 To counter - 1
Sql = "insert into purchaseitem values(" & TextBox3.Text & _
"," & DataGridView1.Rows(abc).Cells(0).Value & _
",'" & DataGridView1.Rows(abc).Cells(1).Value & _
"'," & DataGridView1.Rows(abc).Cells(2).Value & _
"," & DataGridView1.Rows(abc).Cells(3).Value & _
"," & DataGridView1.Rows(abc).Cells(4).Value & _
"," & DataGridView1.Rows(abc).Cells(5).Value & _
"," & DataGridView1.Rows(abc).Cells(6).Value & _
"," & DataGridView1.Rows(abc).Cells(7).Value & _
",'" & ComboBox1.Text & "')"

Dim counter, abc As Integer
counter = DataGridView1.Rows.Count - 1
MsgBox(counter)
For abc = 0 To counter - 1
Sql = "insert into purchaseitem values(" & TextBox3.Text & _
"," & DataGridView1.Rows(abc).Cells(0).Value & _
",'" & DataGridView1.Rows(abc).Cells(1).Value & _
"'," & DataGridView1.Rows(abc).Cells(2).Value & _
"," & DataGridView1.Rows(abc).Cells(3).Value & _
"," & DataGridView1.Rows(abc).Cells(4).Value & _
"," & DataGridView1.Rows(abc).Cells(5).Value & _
"," & DataGridView1.Rows(abc).Cells(6).Value & _
"," & DataGridView1.Rows(abc).Cells(7).Value & _
",'" & ComboBox1.Text & "')"
MsgBox(Sql)
Da = New SqlDataAdapter(Sql, Class1.Connection)
Da.SelectCommand.ExecuteNonQuery()

Hi, so you're saying change AllowDBNull to True, or change it to False? My datatable has all the DataColumns set to True, however whenever I pull a NULL value from SQL, I get an Exception in the GET Method. WTF? This is pretty lame if you ask me... strongly typed but so strongly that you cannot handle NULLs.

This article has been dead for over six months. Start a new discussion instead.