Groups | Blog | Home
all groups > sql server (alternate) > may 2004 >

sql server (alternate) : Returning database schemas


sailent NO[at]SPAM hotmail.com
5/6/2004 10:01:16 PM
Hi, I am storing information being sent to me weekly into a ms sql
database. The one twist I am running into is that later down the line
the information I recieve may require more columns, or columns might
be renamed so having a static database call is out of the question. I
was using mysql but for certain reasons switched to ms sql 2000.
Currently before ms sql, I query the database for show fields which
returns all the database data such as type, column name, etc... then I
use a giant if statement structure to deal with matching and
converting data from my users display to the information into the
database.

So my first question is how do I either query or using datatypes built
into C# return information about a tables setup. I was hoping there
was some sort of table array object which could be returned with names
and types, if not then just an sql statement return.

My second question is I have user data which needs to be displayed
differently then the database raw data, how do I use a C# dataset, and
convert it's column data into my raw database data without having to
create raw insert and update sql strings myself? I would really like
to use the sort of automatic update features of the dataset.

Lastly am I going about this the wrong way? Are there other ways to
sql NO[at]SPAM hayes.ch
5/7/2004 5:32:09 AM
[quoted text, click to view]

Have you looked at the INFORMATION_SCHEMA views?
INFORMATION_SCHEMA.COLUMNS has details about every column, including
data type etc. Or there is sp_help, but it returns multiple result
sets, so it may not be so easy to work with.

Regarding your dataset questions, you might get a better response in a
..Net development group.

AddThis Social Bookmark Button