DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Question regarding writting a C# Database driven windows application

  1. #1
    Join Date
    Apr 2005
    Posts
    1

    Question regarding writting a C# Database driven windows application

    I have questions regarding design considerations for a C# Windows application that will be using SQL Server:

    1. One of the considerations for this application is that it might be ported to another database platform like MSql in the future. With that in mind is there any way to completely separate the presentation layer from the data layer. An example. If I wanted to populate a combo box with some selections from a database I would create a dataset and then iterate through the records.

    I think the best way to ask this question is: Is there a way to populate the combo box with data without mixing code that refers to a specific type of connection or dataset? Is there a way to architecture the code so that when I make a call to populate the combo box where the data is coming from (SQL Server, MySQL) I can do so without knowing being concerned where the data is coming from?

    2. Connection Pooling. I am not sure I completely understand this, but what I have read one of the key points of connection polling is that all the connections have to use the same exact connection string. Does this mean that there is one id and password that used by all connections? Is connection pooling appropriate for applications where different levels of security are going to be needed?

    3. What is best way to architecture a windows based database driven application:
    a. Connect to the database on application start up and then maintain that connection in a public variable for the duration of the application session
    b. Connect and then disconnect to the database each time that you need to interact with the data layer?

    Thanks for any comments on these questions

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    Quote Originally Posted by smgrisw
    I have questions regarding design considerations for a C# Windows application that will be using SQL Server:

    1. One of the considerations for this application is that it might be ported to another database platform like MSql in the future. With that in mind is there any way to completely separate the presentation layer from the data layer. An example. If I wanted to populate a combo box with some selections from a database I would create a dataset and then iterate through the records.

    I think the best way to ask this question is: Is there a way to populate the combo box with data without mixing code that refers to a specific type of connection or dataset? Is there a way to architecture the code so that when I make a call to populate the combo box where the data is coming from (SQL Server, MySQL) I can do so without knowing being concerned where the data is coming from?
    The answer depends upon the providers you will be using. If you use the SQL Server specific provider then you will likely need to switch your provider to one which supports MySQL if that is the database you're going to switch to. There is no guarantee they will be compatible so at a minimum your DataAdapter will need to be changed. The DataSet/DataTable classes are database agnostic so it isn't likely you will need to make any changes. Either the DataReader or Command classes (if used) may also require changes.

    2. Connection Pooling. I am not sure I completely understand this, but what I have read one of the key points of connection polling is that all the connections have to use the same exact connection string. Does this mean that there is one id and password that used by all connections? Is connection pooling appropriate for applications where different levels of security are going to be needed?
    Yes, connection pooling requires that all requests for a connection use the same exact connection string. It's automatically enabled if the provider supports connection pooling capability. Assuming you're working on a desktop application, your connections would typically occur on the desktop machine, unless you're using remote components. In this instance the pooling occurs on the client.

    3. What is best way to architecture a windows based database driven application:
    a. Connect to the database on application start up and then maintain that connection in a public variable for the duration of the application session
    b. Connect and then disconnect to the database each time that you need to interact with the data layer?
    I would recommend b. Fewer database resources are in use at any one time and you can still take advantage of connection pooling on the client.
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center