SQLClient SQLAdapter Data type problem
- From: rj <rj@xxxxxxxxxxxxx>
- Date: Thu, 16 Nov 2006 01:25:32 GMT
I'm having problems simply retrieving values from the database and using
in their original format. Example below assumes that size column is
double or float
Here is code snippet:
string maxSize;
string source = "Data Source=server_name; Initial Catalog=testing; User
ID=bj; Password=pass";
SqlConnection conn = new SqlConnection(source);
string select = "select max(size) from sizes";
SqlAdapter da new SqlAdapter(select, conn);
DataSet ds = new DataSet();
da.Fill(ds, "maxSize");
foreach(DataRow in ds.Tables["maxSize"].Rows)
{
maxSize = row[0].ToString();
}
Everything works here but how I go about it if I need maxSize to be
double or float? if I do maxSize = (double)row[0]; I get "cannot
explicitly convert object to double" There is something I don't quite
understand. And if query returns only one row, how can I get the size
value without using foreach?
Thanks in advance
.
- Follow-Ups:
- Re: SQLClient SQLAdapter Data type problem
- From: Bob Barrows [MVP]
- Re: SQLClient SQLAdapter Data type problem
- Prev by Date: SQLClient SQLAdapter Data type problem
- Next by Date: Re: URGENT !!! Operation must use an updateable quary
- Previous by thread: SQLClient SQLAdapter Data type problem
- Next by thread: Re: SQLClient SQLAdapter Data type problem
- Index(es):
Relevant Pages
|
|