473,399 Members | 2,774 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,399 software developers and data experts.

OleDbConnection DataSource configuration

Hello All -

I've got a couple of .NET Windows forms that have associated
OleDbDataAdapters and OleDbConnection. What is the best approach to
implementing a method for configuring the location of the underlying
data source.

I would like to be able to toggle (in code) between Development, Test,
and Production databases. Lets say for example:

dev db: "c:\databases\dev\myDB.mdb"
test db: "s:\databases\test\myDB.mdb"
prod db: "s:\databases\prod\myDB.mdb"

It seems like I need to set the connection's DataSource property prior
to establishing a connection. But if the connection is associated
with the form, how can I configure the connection in code prior to
loading the form?

Thanks!
Dave
Nov 20 '05 #1
2 1426
Will this work.

If the development and test db's are static can you hard
code them in your source (i.e. as a string array) and have
the production db accessible through a dialog box.

You could test the connection for functionality by
entering relevant connection string data and calling the
open and close methods from within a Try Catch EndTry
Control structure.

ie
Dim DBDiaolg As New OpenFileDialog
If DBDialog.ShowDialog= DialogResult.OK Then
ConnectionString= DBDialog.OpenFile
Dim oleDBConnect As New OleDBConnection(ConnectionString)

Try
oleDBConnect.Open
oleDBConnect.Close 'Or you could leave it open for
subsequent operations
Catch
MsgBox("Incorrect DB")
End Try
End If
OpenForm
-----Original Message-----
Hello All -

I've got a couple of .NET Windows forms that have associatedOleDbDataAdapters and OleDbConnection. What is the best approach toimplementing a method for configuring the location of the underlyingdata source.

I would like to be able to toggle (in code) between Development, Test,and Production databases. Lets say for example:

dev db: "c:\databases\dev\myDB.mdb"
test db: "s:\databases\test\myDB.mdb"
prod db: "s:\databases\prod\myDB.mdb"

It seems like I need to set the connection's DataSource property priorto establishing a connection. But if the connection is associatedwith the form, how can I configure the connection in code prior toloading the form?

Thanks!
Dave
.

Nov 20 '05 #2
Cor
Hi Dave,

I think you use the drag and drop method from the toolbox with the
dataadapter.

This is a question that is often been in this newsgroup and there have never
been an answer.

It seems that with that method you are sticked with the connection you make
the first time.

Till now is the alternative not using it and do all the work by hand.
(Not that difficult when you know how).

I know it does not help much, but it prevents you thinking that you are
looking for something simple and that you are stupid.

I hope there is someone (maybe you) who corrects me and gives an answer how
to do it with this drag and drop adaptermethod method.

Cor
Nov 20 '05 #3

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

Similar topics

0
by: no-spam | last post by:
Hello group, I have some questions concerning configuring and using a JNDI DataSource with PostgreSQL and Apache Tomcat. Currently, I belive I have successfully configured a "basic" DataSource....
0
by: ecowalker | last post by:
Hello, I've try the following code in the ASPX and it throw a Security Exception in the runtime, but I've try to run on my colleagues machine without any problem. I am using XP Pro and IIS5.1...
2
by: Daniel Conlon | last post by:
I wish to allow ASP.NET pages to make connections to Access databases using OleDBConnection. The only way I have been able to make this functionality work has been to set: Unrestricted="true"...
5
by: Ron | last post by:
I have a bunch of Crystal Reports (v9) published as WebServices and use a ReportViewer to display the reports on the ASPNET page. Everytime we move the reports from dev to production we have to...
6
by: Bob Achgill | last post by:
I would like to set the DataSource path on my Oledbconnection so that the Windows application will always look in the place where the binary is stored when it looks for the Access database file. ...
4
by: Curtis | last post by:
Which is preferred or what is the difference? SQLConnection or OLEDbConnection. We are connecting to data in MSSQL2000 primarily through stored procedures.
9
by: rroman | last post by:
I've created an OleDBConnection with a corresponding dataAdapter and a dataSet. In development I am able to retrieve records and display them fine. Once compiled no records are returning. I'm...
0
by: CyberLotus | last post by:
Hi, I've created a web application and through this I want to import Excel data to database. Following is the code that I've written, ...
3
by: msch-prv | last post by:
I'm having a format error with OleDbConnection (Format of the initialization string does not conform to specification starting at index 0) with the following. (The line referred to by the compiler...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.