Data Sets

B

brian

I tried opening 2 readers with the same connection and
soon found out that can't be done. I found out I need to
use a data set because that is a disconnected set. Can
someone tell me how to create a data set? And also
(mainly) to search through the data set for a particular
record as you do with a reader.

All the info I can find in the groups shows how to fill a
data adapter which I believe is close to what I need.

Thanks
 
H

Hermit Dave

DataSet myDS = new DataSet();

thats how you create it...
you can use filter on a datatable within a dataset
DataTable myDT = myDS.Tables[0];

to filter data
http://authors.aspalliance.com/olson/methods/FilterSortData.aspx

or you can manually iterate the DataTable
foreach myDataRow in myDt.Rows
if(myData.Columns["column"].value == "xyz") (think its value... )
{
do this;
}
------------------------------------------------------- from one of my data
layer objects
SecureHandling mySH = new SecureHandling();

SqlConnection myCon = new
SqlConnection(mySH.Decode(ConfigurationSettings.AppSettings["online"]));

try

{

SqlDataAdapter myCommand ;

if(ShowOnlyActiveSizes == false)

myCommand = new SqlDataAdapter("sp_CDB_AvailableSizes_SelectAll", myCon);

else

myCommand = new SqlDataAdapter("sp_CDB_AvailableSizes_SelectActive", myCon);

myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;


DataSet mySizes = new DataSet();

myCon.Open();

myCommand.Fill(mySizes, "mySizes");

return mySizes;

}

finally

{

myCon.Close();

myCon.Dispose();

}


--
Regards,

HD

Once a Geek.... Always a Geek
 
B

brian shannon

Thanks for your quick reply- How am I telling what the DataSet is to be
filled with? I would like to fill it with a SELECT statement for SQL.


DataSet myDS = new DataSet();

thats how you create it...
 
H

Hermit Dave

SqlConnection(ConfigurationSettings.AppSettings["online"]);

try

{

SqlDataAdapter myCommand ;

myCommand = new SqlDataAdapter("SELECT * FROM Authors", myCon);

myCommand.SelectCommand.CommandType = CommandType.Text;

DataSet myAuthorDS = new DataSet();

myCon.Open();

myCommand.Fill(myAuthorDS, "myAuthors"); // here you are specifying the
name of the table and the dataset to fill

myCommand.Dispose();

// you can now query the table within.. its name that you specified above is
myAuthors and you asked the command object to fill myAuthorsDS dataset)

return myAuthorDS;

}

finally

{

myCon.Close();

myCon.Dispose();

}


--
Regards,

HD

Once a Geek.... Always a Geek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top