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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Persist with ADO

Status
Not open for further replies.

Kostarsus

Programmer
Nov 30, 2000
86
DE
Hello,

I'm new to ADO.net, so I wrote some little methods for expermentations.
I want to store data with a typed adapter in a filebase database (*.mdf-file). I used the wizards of VS 2010 Express to generate the adapters.
If I run the methode in debug it looks good. The data is persisted. But if I restart the application in debug-mode, the whole data is fanished. So I think, the data isn't persisted right.
If I deploy the code to a real application it looks all right.The data is persisted even if I restart the application.
I've added the code I use. Can you tell me, where I'm wrong?

Code:
        public void insertStaticData()
        {
            testAdapter = new TestTableAdapter();
            ds1 = new DataSet1();
            testAdapter.Fill(ds1.Test);
            try
            {
                testAdapter.Insert(1, "TestText");
                ds1.AcceptChanges();
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
                ds1.RejectChanges();

            }
        }

Thanks in reguards
Kostarsus
 
there doesn't seem to be anything wrong here. although I would question why you need to fill the dataset, just to insert a row.

Are you resetting/recreating the database during debug? this would explain why the data is reset when it's loaded a second time and why the system works in production.

I would recommend not using the VS wizards to write code. wizards teach you how to use the IDE, not how to write code or how the object interact with each other.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
something else to consider, is ORM (object relational mapper) there are benefits to ORMs over DataSets. You can search the web for more insight on that. The biggest advantage is an explicit representation of the model without the cruft of DataSets/Tables.

DataSet still promote a data centric view of the application. they are basically in memory databases. ORM map the database to objects where data & behavior define the application.

I have found only one use for data tables/sets. reporting.

there are 4 main ORMs
Castle.ActiveRecord - oss
Nhibernate - oss
Entity Framework - MS
LLBL Gen Pro - $

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Well because I'm new to AO.net I tried the examples of a book, first.
I don't create the database in program code. I only connect to the file.

In the book, there was not discussion about ORM.
The datasets are mapped by a *.xsd-file. I think this isn't the ORM mapping you'd talked about.
I don't want use the connection by ASP.
Perhaps you hav some more good links where I can find more information about ORM-Mappings.

cu Kostarsus


 
google any of the terms I provided and you will get a plethora of information.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top