It's not terribly difficult - here's a sample of how I (roughly) do
this. I actually have a class that handles all of my DB stuff for me,
but here's an approximation.
string conn = "<APPROPRIATE CONNECTION STRING>";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "<STORED PROC NAME>";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = new SqlConnection(conn);
try
{
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.SelectCommand.Connection = cmd.Connection;
DataSet _dset = new DataSet();
// Automatically opens DB, gets the information, then closes it
sda.Fill(_dset);
}
// Send an error if something went wrong.
catch (Exception ex)
{
emailErrorMsg(ex.Message);
}
Robin wrote:
How much coding is required? Are there any resource explaining how to
create data adapters (plus other required data objects) just in code?
"Cowboy (Gregory A. Beamer) - MVP"
<No************@comcast.netNoSpamM> wrote in message
news:7F**********************************@microsof t.com... Unfortunately, you will have to keep reconnecting the Adapter if
you use
the built in Drag and Drop stuff in the IDE. You can edit the connection
string, but the code is regenerated each time you muck with it. I tend to
shy away from drag-and-drop for this reason.
---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"Robin" wrote:
When adding a SQL Data Adapter to a page, is possible to
configure it use a connection string in code?
As I have found it regenerates the code each time and of the
adapters are modified and does not allow the generate dataset option to be
used.