StringConnection

  • Thread starter Thread starter philip
  • Start date Start date
P

philip

I would programatically choose between two Access Databases. They are both
the same structure. Only data change.
How can I programatically say : "now, I change the database ?"
I saw that the origin of the database is writen in an xsd file. By which
property of which object can I programatically change the stringconnection
to go from a database to another ?

The reason is simple : to debug my program more quickly, I use a reduced
database, but I would use another database in another directory (the
original database is much greater) when I test the '.exe' release version of
my program. If I can programatically change database, I can easily change
the procedure to go from the first to the second.

'My.Settings.starDvdDataConnectionString' is ReadOnly.

Thanks for your help
 
I tried this address, but vb2005 don't recognize the object
'ConnectionStringSettings', even with 'Sytem.Configuration'.
Must I add a special reference ?

Thanks for your attention.

Philip
 
Philip,

Be aware that you only need a very small part of this sample

Did you see in top of it
'Set a reference to System.Configuration

And did you do that.

I hope this helps,

Cor
 
'System.Configuration.ConnectionStringSettings' in not recognized, even with
'Imports System.Configuration'
Error is "Type 'System.Configuration.ConnectionString' is not defined".

Do you see why ?

I use Visual Studio 2005 pro.

Thanks for helping me.

Philip
 
Philip,

Import is only setting the shortcut for the namespace.

A reference is set with (as I do it)

Project (or Website) -> add reference -> choose the reference

I hope this helps,,

Cor
 
When I add my access Database to my project, VS2005 created a general
dataset with all the tables.
It creates also a 'MyDataBaseConnectionString' for this dataset.
All the hidden system use this string for the gestion of the connection
between the general dataset and the database.
With the example given by Ken Tucker, I understood how using
'ConnectiongStringSettings' to define a connection for a command.

BUT my problem is to can modifiy the name of the database at the beginning
of my program. 'My.Settings.MyDataBaseConnectionString' is ReadOnly.
And I don't know how use 'ConnectiongStringSettings' to modify the general
connection of my general dataset.
Which property permits to define the connection string of a general dataset?
In file 'MyDataBaseDataset.xsd', I see that hidden program use the
'MyDataBaseConnectionString'.
How can I change the name of the database without touching the hidden code ?
How can I use (and CAN I do it) the 'ConnectiongStringSettings' to modify my
'MyDataBaseConnectionString'

Thanks for your help.
 
Philip,

Your connectionsstring is not hidden. It is in designer generated code
normally in the app.config

For most of us helping here is the problem that we have used the designer
generated code in version 1.x only to try things. It was to confusing, I am
in doubt if I will use it in 2.0 because that looks at least much better.

If you cannot come further after this message. Can you than show us the
piece of code where you fill the dataset. It comes than probably clearer for
us, and than we can maybe help you better with that.

Cor
 
I solve the problem using a public String that I called ConnString.
And each time a TableAdapter must fill my datasets correponding to the
tables on my Access Database I specify the connection like this :
Dim Conn As New OleDb.OleDbConnection(ConnString)
Me.MoviesTableAdapter.Connection = Conn
Me.MoviesTableAdapter.Fill(Me.StarDvdDataDataSet.movies)
So the program don't use the ConnectioinString created by itself in the
Settings of the application.

Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top