ADO.NET problem

N

nashak

Hello,

I am trying to build a database project and have the following.

I have one table "Subject" in sql server.
I have a dataclass Data1
I have a business class Business1
I have a connection class Connection1 that instantiates and returns a
new sqlconnection object

Business1 calls connection class and gets a new connection.
Now Business1 instantiates Data1 object. New() creates a new
dataadapter, 4 sqlcommand objects and assigns them to the
dataadapter.command and creates a dataset object
Now Business1 calls GetEmptyRecord() of Data1 and passes name of a
table and connection object
In GER() I assign a sql to commandtext, set commandtype and connection,
create new table, add to dataset, fills dataset using fillschema,
create emptyrow in table. Now I pass this datarow to Business1.

Is there any way in which I can find the column names of the columns in
this datarow. Since i filled table with fillschema it should have the
column names and I want to avoid hard-coding column names in my code.
Also, is there a way to automatically generate update, delete and
insert sql commands? I tried using commandbuilder but that is not
working.

Thanks,
 
M

Marina

There is a Columns collection in the datatable that has all of them. You
have to looks in there, not the datarow for the columns and their names.

As for commandbuilder, that is your only option. You will need to be
specific as to the error message, because in general that works. The
requirements are that your SELECT has no joins in it, and that the columns
names are either all non-keyword names or you set the quoteprefix and
quotesuffix properties on the commandbuilder appropriately.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top