Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

db->table adapter->schema->dataset->binding source - HUH? 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
I'm totally confused trying to get my head around connecting to databases in .NET, in the 20 years i've worked with them i've never come across such a conveluted, complicated and mind boggling way of doing things.

why on earth are there so many 'middle men' objects that don't talk to each other?

if you insert or delete, it directly updates the DB , but not the dataset, so the view is out of sync, if you edit the dataset and the db has a record inserted, the record gets lost when the dataset changes are sent to the DB.

How can two people running the same app even function, you are going to constanly be out of sync with each other, trash each others data changes and totally corrupt the DB.

this doesn't make any sense to me, what ever happend to using SQL and simply refreshing the view?

I cannot see how it is even possible to write a DB application under these circumsatnaces and so any light you can shed is appreciated.

I normally use MS Access (VBA), and am considering moving to VB.NET, but I can't get my head round how to ensure data integrity.

Your input is appreciated.

Thanks,
1DMF



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
ADO.Net uses a disconnected model - data is manipulated in memory on the client which is then optionally communicated back with the database server. Here is the plain, basic way to work with .Net data access.

1. Create a Connection object
2. Create four Command objects: one each for select, insert, update and delete. Those Command objects use the Connection object from #1.
3. Create a DataAdapter. DataAdapters have properties to reference your different commands.
4. Create a DataTable, or DataSet if you are bringing in multiple tables. Your DataAdapter will fill your DataTables via your Select commands, or update your database based on changes to your DataTables.

 
Thanks RiverGuy.

It is a little clearer now, I still think designing a full scale DB application is going to take a while to get my head round, especially coming from Access that does a lot of the work for you and connects direct to the SQL DB.

When you say create four command objects, are these DB functions or fill methods?

Where do I create them? as queries through the VB IDE against the datasource?

Cheers,

1DMF.


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Command objects in your .Net code. If you're using SQL Server, they would be like
Code:
Dim cmdSelect As SqlClient.SqlCommand
Dim cmdInsert As SqlClient.SqlCommand
Dim cmdUpdate As SqlClient.SqlCommand
Dim cmdDelete As SqlClient.SqlCommand

Each command object will have a Connection, CommandText, CommandType (is it a sql statement or a stored procedure reference), and Column/Field mappings. When the .Fill method of your DataAdapter is called, it knows to use your select command object since you've set that DataAdapter's .SelectCommand property.
 
Thanks, looks like in need to have a play and see how i get on.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top