473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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 )
programmatically 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
programmatically ? 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 18 '07 #1
1 2445
Hi Orit,

Your connection string can be based on criteria. If the user selects
something, then the user will invoke whatever connection meets the
criteria for the selection. If the sql server is the mirror for the
Access mdb, then you can do something like checking if the connection to
the Access mdb works. If the connection state is invalid (error) then
create a sql connection. Or if the User selects from one dropdown box
on your webpage the User invokes one connection - if not -then the other
connection.

Once a process is completed you need to close the connection. You
should open the connection for each interaction and then close the
connection right away. There is no need to keep a connection open -
especially for ASP.Net since you can create in memory datasets at the
client side (for dropdowns, datagridviews, etc).

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Jun 18 '07 #2

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

Similar topics

0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
3
by: Alberto | last post by:
I have an object SqlConnection and I changed the connection string property in the properties windows. The object works fine but if I do the same declaring the object connection by code and with...
0
by: Jay Douglas | last post by:
Hello, I'm trying to create a Data Links Property window that behaves just like the dialog box in Visual Studio .Net for MS Sql Server connections. I've found a lot of examples that use...
1
by: andrewcw | last post by:
I get an "Could not find installable ISAM." But the error does not make sense. to me. I converted this code to C# that I found on the internet: ( ...
7
by: Wayne Wengert | last post by:
I am using VB with a Windows NET application. I have a datagrid in which the user can add rows using the "*" row. I want to detect whenever the user has added a row. I found the following code at...
1
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while...
2
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...
5
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
How can I get the list of connection string's keywords available in sqlclient programmatically? I have found the list in here...
0
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.