troubleshooting Question

SQL in C# - Grabbing a single value

Avatar of KyleG
KyleG asked on
11 Comments1 Solution886 ViewsLast Modified:
I'm quite new to C# (I've programmed in C++ until now) and also don't have a whole lot of experience working with databases and SQL.

I'm currently working on a windows application that uses a database and have been relying on Visual Studio 2005's built-in controls to handle it for me (i.e. binding data to textboxes etc.). Now I need to be able to grab a value out of one of the tables (I know exactly which value) to use it in some calculations, but I don't know how to put the value into an int variable. This is what I want to happen:

int ta500stock = this.rentalManagerDataSet.StockList.Select("February WHERE (Product = 'TA500')");

*Note: StockList is the table and February is the column that I want the value from.

Now, the compiler tells me that I "Cannot implicitly convert type 'System.Data.DataRow[]' to 'int'" which makes sense, but I don't know how to set it up so that I can grab the value and store it as an int.

Any suggestions, advice, or links would be much appreciated.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros