简体   繁体   中英

Pass null value as parameter in DataSet

I have fill method to get data from DB to dataSet that is like

Select * from table 
where (columnName = @parameter) OR (@parameter is null)

and in CS, its like

tableadapterObject.Fill(datasetObj.tableName, @parameter)

that works fine, but when I try to pass null

tableadapterObject.Fill(datasetObj.tableName, null)

It gives error.. {"Value cannot be null.\\r\\nParameter name: columnName"}

How could I Pass null value to parameter?? Any kind of help will be appreciated.

  • Go to the dataset designer to this table-adapter
  • click on the properties of this query
  • click on the Parameters
  • change Allow DbNull from false to true .

在此处输入图片说明

(german IDE and other parameter, but you should understand what i mean)

Change the property "AllowDBNull" to true. Please refer the below link.

http://msdn.microsoft.com/en-us/library/ms233762.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM