Modifying / Displaying info from SQL server

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I'm a newbie to C# and .NET, so please be gentle! My limited background is
in VBScript,ASP, and Access dbs.

I need to retrieve data from a SQL server db (8.0) to be displayed in a
table format on a web page. I also need to do some major calculations with
the numbers from the DB, and insert them into the table. ie, if (field =
something) then display a row of calculated values.

I've tried using a SqlDataReader, but it seems I can't format the numbers
the way I want them (it grabs the field value as an object and I can only
convert them to strings, but I need them as numbers). Datagrids are only good
with grabbing and displaying, without modifying the info much.

Maybe I'm just missing something with retrieving the fields as numbers using
sqldatareader...

Anyway, what's the best/easiest way to implement what I've described above?

Thanks in advance for any suggestions!
 
The declared type is object in the indexer. But the actual type will be an
integer, if that is what you retrieved from the database. You can cast it to
any object type - no one says it can only be a string.

The datagrid also allows you to define format masks for the fields.
Additionally, you could in theory do all your formatting in the SQL itself,
so all the data is already formatted once you retrieve it.

I suggest you take some time out to look at some sample online of doing all
this. There are plenty of them, you should be able to adapt them to fit your
needs.
 
I figured out my problem with converting. I need to do
mySqlDR["fieldname"].GetType() in order to figure out what to cast the obejct
to. (duh)

Thanks for the advice.
 
Back
Top