简体   繁体   中英

DATAADAPTERS AND NULLS

I am trying to pass a null to DataAdapter.Fill. My SQL statement accepts nulls but I get a return that nulls are not acceptable.

JUEGO.etreDataSetTableAdapters.CountyTableAdapter etreDataSetCountyTableAdapter = new          JUEGO.etreDataSetTableAdapters.CountyTableAdapter();
        etreDataSetCountyTableAdapter.Fill(etreDataSet.County, null);
        CollectionViewSource CViewSource = ((CollectionViewSource)(this.FindResource("CViewSource")));
        CViewSource.View.MoveCurrentToFirst();

the CountryTableAdapter has the SQL Statement below behind it.

SELECT DISTINCT CCODE FROM  HH_Match WHERE  (@DCODE IS NULL OR DCODE = @DCODE)

but when I pass Null like above it returns a massage that nulls are not allowed. I am working in Visual Studio (C#) 2012. Thanks in advance for the help

You have to configure the TableAdapter manually so that it accepts null.

Therefore click on Parameters in the query property. Select the parameter you want to make optionally (in this case you have only one parameter). On the right side you'll find AllowDbNull . Set this to True and you've arrived.

在此处输入图片说明

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