473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Modifying / Displaying info from SQL server

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!
Aug 4 '05 #1
2 1353
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.

"Rose" <Ro**@discussions.microsoft.com> wrote in message
news:A8**********************************@microsof t.com...
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!

Aug 4 '05 #2
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.
Aug 4 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sp33di3 | last post by:
I've been searching and searching for this and there are lots of posts - but very few answers. I have a SQL2000 Database that has jpg images in a table that I want to display in a webpage. I...
2
by: yvan | last post by:
I was wondering if someone here could help me with modifying this PHP template so that it does something very specific for me. My knowledge of PHP is very limited (I'm more of a Cold Fusion...
2
by: Rose | last post by:
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...
1
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
20
by: Tim Reynolds | last post by:
Team, I am developing a web service. In testing in on my enw PC, I am expecting to see exceptions thrown appear on my browser. Instead I am getting an HTTP 500 Internal Server Error page and I am...
1
by: VMI | last post by:
I'm working on an ecommerce-type we app, and I would like to save/retrieve image information into my sql server DB. If I save the file path in my table, how can I use that info to display the...
3
by: Objectifnet | last post by:
Helo, please is there anyone who can help out with this; I have a script that displays details from a MYSQL database and a File Server containing images. Here is the code below: My problem is:...
3
by: GeekyChicky79 | last post by:
Hi Everyone, I have the project below where I'm pulling out information from 1 table "Subjects", pulling the Subjects, and SubjectCode. The Subjects are displaying in the Combo Box just fine,...
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.