Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Using ADO.NET in Windows Forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sheperson@googlemail.com - 18 Mar 2008 23:09 GMT
Hi,
I have always had a problem when programming with ADO.NET and Windows
Forms.
It is about how to access database through WinForms. For example I
have an application with several forms and each form deals with a part
of the database. There are some options available:
1- I can create a dataset in the main  Form, fill it with data from
the database, and then pass it to other child forms as an argument.
The child forms do what they want with the dataset and at the end, the
main Form updates the database with the new information.

2- Each form has it's own dataset, connects to the database, fills the
dataset and then updates the database when it wants to be closed.

But non of the above approaches are good.
I wonder if anyone has an idea about it.
Thanks in advance.
Devin - 19 Mar 2008 01:36 GMT
On Mar 18, 6:09 pm, "sheper...@googlemail.com"
<sheper...@googlemail.com> wrote:
> Hi,
> I have always had a problem when programming with ADO.NET and Windows
[quoted text clipped - 13 lines]
> I wonder if anyone has an idea about it.
> Thanks in advance.

As an alternative:

You could create a separate class with in the same namespace that
contains the dataset as a static member. That way you will only have
to fill it once and use it/update it where ever you needed to.

Devin
Mr. Arnold - 19 Mar 2008 03:34 GMT
> Hi,
> I have always had a problem when programming with ADO.NET and Windows
[quoted text clipped - 13 lines]
> I wonder if anyone has an idea about it.
> Thanks in advance.

As far as I am concerned, it's poor design concept. The only thing you
should be doing with a dataset at the UI is to fill a grid, combox
listbox --- a read only situation. Maybe, the information below will give
you some guidance.

MODEL-VIEW-PRESENTER
http://www.polymorphicpodcast.com/

click 'Shows'

click 'Design Patterns Bootcamp: Model View * Patterns'

view part 1, 2, 3, 4, 5
sheperson@googlemail.com - 20 Mar 2008 09:21 GMT
> <sheper...@googlemail.com> wrote in message
>
[quoted text clipped - 30 lines]
>
> view part 1, 2, 3, 4, 5

Thanks so much. It took along time to download those shows using my
dial-up connection!!!.
Saimvp - 19 Mar 2008 11:11 GMT
Hello my friend. try this and I hope it can help.

//create dataset function

       public static DataSet Execute(string Sql)
       {
           OleDbConnection CON = new OleDbConnection();
           CON.ConnectionString = "YOUR CONNECTIONSTRING";
           CON.Open();

           OleDbCommand cmd = new OleDbCommand(Sql, CON);

           DataSet ds = new DataSet();

           OleDbDataAdapter da = new OleDbDataAdapter(cmd);
           da.Fill(ds);
           return ds;
       }

// THEN AT YOUR FORM1 LOAD

//declare a string
string MYstring = "select * from [table]";

//set datasource for you gridview
datagridview.datasource= YOURCLASS.execute( MYstring ).tables[0];

Signature

To be Happy is To be Yourself

> Hi,
> I have always had a problem when programming with ADO.NET and Windows
[quoted text clipped - 13 lines]
> I wonder if anyone has an idea about it.
> Thanks in advance.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.