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 / Windows Forms / WinForm General / June 2007

Tip: Looking for answers? Try searching our database.

how to pass connection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
drama - 10 Jun 2007 11:56 GMT
information  from form1 to form2 one time in holle project

form exitample
-------------
public partial class Form1 : Form
   {  public Form2 f2 = new Form2();
       public Form1 f1 = new Form1();
        string st = "server=localhost;user id=root; password=;
database=nwin; pooling=false";

       public MySqlConnection conn = new MySqlConnection();
               conn.connectionString=st;
conn.open( );  // connection is opening now
.
.
.
-.*----
-          ----
------now FORM2
public partial class Form2 : Form

   hot to get that "conn" from form1
Alex Meleta - 10 Jun 2007 12:33 GMT
Why do you need to keep the connection info in presentation level (Forms)?

The best way is to allocate any DAL information in a separated class and
extract any data from here. The form should not need to know anything about
it. So, keep your connection string in config file and make your forms received
info from some DAL-class, which incapsulate all work with DB layer.

ps. also don't pass the openned connection. you should open and close connection
asap. the data layer always have limited connections.

Alex
http://devkids.blogspot.com

> information  from form1 to form2 one time in holle project
>
[quoted text clipped - 16 lines]
> public partial class Form2 : Form
> hot to get that "conn" from form1

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.