473,748 Members | 8,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I change a connection string of the object data source programmaticall y ?

Hello .

Please find below my questions - I hope some of the ASP.NET experts of
this forum will answer to those beginner's questions :

My Web site should be able to work with either SQL Server or Access
database as following :

It will connect first to the Master database (SQL or Access,
connection String of this database should be read from the C:\WINDOWS
\XXX.INI file).
It will have one or more sub-databases ( SQL Or Access , list of sub-
databases is saved in one of the Master tables .)
The schema of all sub-databases is the same , no matter if this is
Access or SQL .

My site should present sub-databases drop-down list ( which will be
retrieved from the Master database ) and then will connect to
specified sub-database ( either Access or SQL ) and will display data
from this database .
I would like to be able to switch database type ( database provider )
programmaticall y on the data source level so it is transparent for the
application code .
Can I do it ?
Can I change a connection string of the object data source
programmaticall y ? If so , how can I do so ?
Can I then call the same methods which will call Access or SQL
database as needed ?
Or . should I create different table adapters , specify SQL connection
string for one of them , OLEDB connection string to another ,
duplicate all methods and have a if/else block each time I call a
methods of those adapters ?
If so , would it be easier then NOT to use data objects and use just
different providers ?
Do I miss something here ?

Thanks in advance for your help ,
Orit Chanukov .

Jun 19 '07 #1
2 3265
I think that you will have to use different DataAdapters with the If
statement like you mentioned. Because SQL Server and Access use different
DataAdapters, Connections, and other objects for accessing databases, you
would end up writing the code for each of them separately anyway. The
connection string can be changed programmaticall y using the ConnectionStrin g
property of the connection (this property is inherited from the
System.Data.Com mon.DbConnectio n class, so all the connection types have it)
One thing that may come in useful at some point in your code (or maybe not,
I haven't seen your code and algorithms) is using the parent classes, such
as System.Data.Com mon.DbConnectio n, and assign the appropriate connection
type to it. This could help you organize your variables in some situations,
you decide what your preference is. The reason there is not an easier way to
do this is because applications are not expected to use multiple database
providers in the same application. Good Luck!
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Orit" <or******@gmail .comwrote in message
news:11******** *************@x 35g2000prf.goog legroups.com...
Hello .

Please find below my questions - I hope some of the ASP.NET experts of
this forum will answer to those beginner's questions :

My Web site should be able to work with either SQL Server or Access
database as following :

It will connect first to the Master database (SQL or Access,
connection String of this database should be read from the C:\WINDOWS
\XXX.INI file).
It will have one or more sub-databases ( SQL Or Access , list of sub-
databases is saved in one of the Master tables .)
The schema of all sub-databases is the same , no matter if this is
Access or SQL .

My site should present sub-databases drop-down list ( which will be
retrieved from the Master database ) and then will connect to
specified sub-database ( either Access or SQL ) and will display data
from this database .
I would like to be able to switch database type ( database provider )
programmaticall y on the data source level so it is transparent for the
application code .
Can I do it ?
Can I change a connection string of the object data source
programmaticall y ? If so , how can I do so ?
Can I then call the same methods which will call Access or SQL
database as needed ?
Or . should I create different table adapters , specify SQL connection
string for one of them , OLEDB connection string to another ,
duplicate all methods and have a if/else block each time I call a
methods of those adapters ?
If so , would it be easier then NOT to use data objects and use just
different providers ?
Do I miss something here ?

Thanks in advance for your help ,
Orit Chanukov .

Jun 19 '07 #2
On Jun 18, 9:55 pm, "Nathan Sokalski" <njsokal...@hot mail.comwrote:
I think that you will have to use different DataAdapters with the If
statement like you mentioned. Because SQL Server and Access use different
DataAdapters, Connections, and other objects for accessing databases, you
would end up writing the code for each of them separately anyway. The
connection string can be changed programmaticall y using the ConnectionStrin g
property of the connection (this property is inherited from the
System.Data.Com mon.DbConnectio n class, so all the connection types have it)
One thing that may come in useful at some point in your code (or maybe not,
I haven't seen your code and algorithms) is using the parent classes, such
as System.Data.Com mon.DbConnectio n, and assign the appropriate connection
type to it. This could help you organize your variables in some situations,
you decide what your preference is. The reason there is not an easier way to
do this is because applications are not expected to use multiple database
providers in the same application. Good Luck!
--
Nathan Sokalski
njsokal...@hotm ail.comhttp://www.nathansokal ski.com/

"Orit" <oritc...@gmail .comwrote in message

news:11******** *************@x 35g2000prf.goog legroups.com...
Hello .
Please find below my questions - I hope some of the ASP.NET experts of
this forum will answer to those beginner's questions :
My Web site should be able to work with either SQL Server or Access
database as following :
It will connect first to the Master database (SQL or Access,
connection String of this database should be read from the C:\WINDOWS
\XXX.INI file).
It will have one or more sub-databases ( SQL Or Access , list of sub-
databases is saved in one of the Master tables .)
The schema of all sub-databases is the same , no matter if this is
Access or SQL .
My site should present sub-databases drop-down list ( which will be
retrieved from the Master database ) and then will connect to
specified sub-database ( either Access or SQL ) and will display data
from this database .
I would like to be able to switch database type ( database provider )
programmaticall y on the data source level so it is transparent for the
application code .
Can I do it ?
Can I change a connection string of the object data source
programmaticall y ? If so , how can I do so ?
Can I then call the same methods which will call Access or SQL
database as needed ?
Or . should I create different table adapters , specify SQL connection
string for one of them , OLEDB connection string to another ,
duplicate all methods and have a if/else block each time I call a
methods of those adapters ?
If so , would it be easier then NOT to use data objects and use just
different providers ?
Do I miss something here ?
Thanks in advance for your help ,
Orit Chanukov .- Hide quoted text -

- Show quoted text -
Thanks a lot , Nathan .
That what I thought .
Orit,

Jun 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2101
by: Mike Moore | last post by:
does anyone have an example of how to get the connection string object converted to a string variable type in order for me to call a function?
1
2313
by: Siva | last post by:
Hi, I have a 3 tier ASP.Net app for a handheld which needs to fetch orders from database via a DAL and populate it in a gridview using objectdatasource. In the search page I have a few parameters and when the search button is clicked I am sending those parameters via query string ( I need to do this since my app will run in a handheld which has certain restrictions). In the order list page, I am passing those parameters to the DAL as...
1
2902
by: Ram | last post by:
Hi All, I am using Object Data Source to bind data in the gridview. I have set the property AllowSorting=true. While running the application, I could sort the data only in ascending order. Is there any way to achieve two way sorting in gridview ie. both ascending and descending on successive clicks ?. Please give me a suggestion to solve this issue. Thanks in advance.
0
1188
by: Annie | last post by:
Hello guys, We are planning for a big project ... and in the warming up stages ... we are trying to develop the applicaiton in n-tier. One of the option is to use the ASP.net object datasource to find BO to Controls. I just want to know the pros and cons of Object Data source control based on
1
2461
by: Orit | last post by:
Hello . Please find below my questions - I hope some of the ASP.NET experts of this forum will answer to those beginner's questions : My Web site should be able to work with either SQL Server or Access database as following : It will connect first to the Master database (SQL or Access, connection String of this database should be read from the C:\WINDOWS
2
1967
by: =?Utf-8?B?RGF2ZSBU?= | last post by:
I have a list box that is bound to an object data source. I added a column, say ColumnC, to my typed data set and for it's expression I entered ColumnA + ': ' + ColumnB When I preview the data in the designer I get exactly what I want. Now I go over to the object data source on my web page, refresh it and refresh the schema. I can now see ColumnC as an option for the list box's data text field. However, when I run the page...
3
1996
by: Fresno Bob | last post by:
When you bind to the object data source you can bind to the underlying dataset that is returned by the select statement but can you bind to the properties of the object? MSDN says the objectdatasource can return an object. Say for instance I have a customer object with a name property. Can I bind to it e.g. Text='<%# Bind("Name") %>'
0
1407
by: =?Utf-8?B?Sm9l?= | last post by:
I have a user control that is in a FormView using an ObjectDataSource. When the page renders the form correctly displays the data from the data source. When I then change data and hit update, my update method gets called, but the data is unchanged. aspx page <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestObjectWeb._Default" %> <%@ Register Src="WebUserControl1.ascx" TagName="WebUserControl1"
6
6443
by: little83 | last post by:
Dear all i wrote one class to deal with sql database to insert and read data from that class only...and based on that one of the parmeters or the class is the sqlconnection SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename= {0};Integrated Security=True;Connect Timeout=30;User Instance=True"); so the connection string is defined indepented of the class objects of the class (i mean class objects used...
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9247
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.