hello,
on my latest ASP.NET 2.0 project i decided to try using TableAdapters
in my DA layer for record retrieval. so instead of writing functions
that setup new connection & command & dataadapter objects, i instead
define a TableAdapter query in my project's "tableAdapters.xsd" file.
this adapter/query points to an existing proc, specifies params, and
specifies the return type.
i call them from DA methods like so:
//instantiate one of my adapters
MyTableAdapters.Events adapter = new MyTableAdapters.Events();
//get data
DataTable results = adapter.GetEventsByVenueID(venueID, isFood,
isDrink, isMusic);
...this appears to work w/o any problems that im aware of. two
questions:
1) is this a valid technique? is it enterprise-worthy?
2) some of my SQL Server 2005 procs use optional parameters, which i
track in the proc's SQL logic. but i cant seem to figure out how to
omit optional values w/ the adapter.
example: in the made-up example above id like to optionally omit some
of the bools going into the proc. i know how to do this via normal ADO
command object params -- id just use C# to determine what value to use
for the parameter object's value (bool or DBNull.Value). but i dont
know how to do it w/ the adapter -- passing in a DBNull.Value causes a
compile error since it was expecting a value type of bool. (and yes, i
have gone into the adapter's Parameters collection properties and set
"AllowDbNull=true". still no dice).
...any thoughts?
thanks,
sm