Database connections

Arg81

Well-known member
Joined
Mar 11, 2005
Messages
949
Location
Midlands, UK
Programming Experience
1-3
Just trying to redevelop an app in 2.0 from 1.1 and this is probably an easy answer but I'm just being dumb :D

In my 1.1 app, I had a pop up screen load before the menu, with 3 radio buttons - site1, site2 and site3.
Each site has its own backend database on the SQL server.

Selecting a site set a global variable to TRUE

All i did was have 3 connections on each form, and the dataAdapters.Connections were set using the global variable, i.e.

VB.NET:
If varSite1 = True Then
   me.dataAdapter1.SelectCommand.Connection = me.conSite1
   me.dataAdapter1.InsertCommand.Connection = me.conSite1
   me.dataAdapter1.UpdateCommand.Connection = me.conSite1
ElseIf varSite2 = True Then
   me.dataAdapter1.SelectCommand.Connection = me.conSite2
   me.dataAdapter1.InsertCommand.Connection = me.conSite2
   me.dataAdapter1.UpdateCommand.Connection = me.conSite2
End If

Now with VS 2005, I see that the whole data access is structured completely different!!

Is there a way for me to still have the popup asking for site, then dependant on the answer chose a connection that the DataSet tables then use?

Thanks for any help.

regards,
 
Erm.. we dont edit the xml of the settings file...

However, I'm not giving up.. :D I just might need to watch what's happenening with Remote Desktop or something..

First, try cleaning the projects (Build menu.. Clean... in both debug and release mode), also shut down the ide and go to that path:

C:\Documents and Settings\lukea\Local Settings\Application Data\Company\

And remove the cached folders there to another location (delete them later)
 
I meant there were no duplicates when doing;

Right click the DataSet1.xsd file in solution explorer and choose Open With...
...XML Editor

Moving those folders and running a clean has fixed the problem :)

I've put a BIG post-it note on my monitor to remind me to switch to application-scope before trying to edit the datasets

Thanks again.
 
Hey Guys,

Don't you think it would be just as easy to just type...

VB.NET:
Me.YourTableAdapter.Connection.ConnectionString = "YourConnectionString"

Before filling the dataset?
 
1) No. You have to remember to do it every time
2) No. The Connection property is not publicly accessible to you
3) No. The design of a database doesnt change when an app is finalised
4) No. Factoring code so that common operations are in one place and not repeated throughout code is highly desirable in good practice (see 1)
 
Back
Top