H
hurricane_number_one
Been writing VB6 for years and am now getting up to speed with .NET.
In VB6 I used to create classes for each logical grouping of tables,
then have a recordset in that class for each table. Then I'd have
functions that would populate the different recordsets. I had a
function like this: "getRecordset($SQLStr) as ADODB.Recordset" that
would take care of the connection, opening the recordset, then just
return a disconnected recordset from that query. Then I had a
function called "updateRecordset(RS as ADODB.Recordset)" which just
stored the changes. Everything was self contained and very easy to
deal with.
Now in VB.NET, I see that the dataset is essentially doing something
very similar to what I was doing in VB6. A couple problems I'm having
though.
1) When I finished making changes to a recordset in VB6, I'd just call
my updateRecordset function, which would reconnect the recordset, call
RS.UpdateBatch and take care of all the inserts, deletes, updates for
me. In VB.NET it looks like I have to use the same SqlDataAdapter
that I used to read the data to update the data in order to save my
changes, and I have to write INSERT and UPDATE code for it? Am I
correct, or is there any way to use this the same way as I was using
recordsets?
2) With recordsets, I could specify the read type when I opened the
recordset, which allowed me to set this programatically as needed but
I would always be dealing with the RecordSet type regardless of how I
read the data. With VB.NET, I have to use a dataReader if I want read
only. Is there anyway to programatically set a dataTable to read only
forward-looking, so that it works the same way as a dataReader and I
only have to deal with one data type in my code?
3) I looked at the typed-datasets, but I really hate using wizards or
GUIs to do my code. I like being able to see it all at once and copy
and paste functions if needed. I also need to be able to change the
connection string on the fly, because I will be using different
servers and database names. Is there any way to create typed-datasets
programatically?
Any suggestions on guides to help me design a good back end for my
program?
In VB6 I used to create classes for each logical grouping of tables,
then have a recordset in that class for each table. Then I'd have
functions that would populate the different recordsets. I had a
function like this: "getRecordset($SQLStr) as ADODB.Recordset" that
would take care of the connection, opening the recordset, then just
return a disconnected recordset from that query. Then I had a
function called "updateRecordset(RS as ADODB.Recordset)" which just
stored the changes. Everything was self contained and very easy to
deal with.
Now in VB.NET, I see that the dataset is essentially doing something
very similar to what I was doing in VB6. A couple problems I'm having
though.
1) When I finished making changes to a recordset in VB6, I'd just call
my updateRecordset function, which would reconnect the recordset, call
RS.UpdateBatch and take care of all the inserts, deletes, updates for
me. In VB.NET it looks like I have to use the same SqlDataAdapter
that I used to read the data to update the data in order to save my
changes, and I have to write INSERT and UPDATE code for it? Am I
correct, or is there any way to use this the same way as I was using
recordsets?
2) With recordsets, I could specify the read type when I opened the
recordset, which allowed me to set this programatically as needed but
I would always be dealing with the RecordSet type regardless of how I
read the data. With VB.NET, I have to use a dataReader if I want read
only. Is there anyway to programatically set a dataTable to read only
forward-looking, so that it works the same way as a dataReader and I
only have to deal with one data type in my code?
3) I looked at the typed-datasets, but I really hate using wizards or
GUIs to do my code. I like being able to see it all at once and copy
and paste functions if needed. I also need to be able to change the
connection string on the fly, because I will be using different
servers and database names. Is there any way to create typed-datasets
programatically?
Any suggestions on guides to help me design a good back end for my
program?