Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Get Values From Database Into Variables

Status
Not open for further replies.

anthonymeluso

IS-IT--Management
May 2, 2005
226
US
Kinda new to all this. I just want to run a selectcommand and have it return its one colunm into variables from a database. Is this possible. I could use an array if need be.

What about datasets. Is it easier to place the the results in there and then get them into my variables?

Thanks,

Anthony
 
You will need a dataadapter to fill a datatable. The datatable will have: Columns defined by the select statement and rows filtered by where statements. If the datatable is dt, then

dt.Rows(integer).cells(integer or col name).value returns a value

The above line is wrong.. i think it works on windows applications, but you get the idea.

A DataSet is a collection of DataTables. After filling the datatable use it. Why loading its contents in an array?

The code to do that could be something like:

DataTable dt=new DataTable;
System.Data.SqlClient.SqlDataAdapter da=new System.Data.SqlClient.SqlDataAdapter;
da.SelectCommand.CommandText="...";
da.Fill(dt);

* May have some errors or not work at all, but again i think you get the idea. (hate c*)
 
You may also want to check out faq855-5662 (and modify it to set a variable rather than writing directly to the page)


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks I just used a repeater and a clever query to get what I wanted done.

Anthony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top