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,
 
The dataset uses the connection string it finds in the application preferences to determine which db to connect to. It manages the connections for you and you have no control over that..


As a hack I perform between connecting to our dev, test and live databases (all the same schema) I do this:

Make a project
Add a database
Allow the connection string to get set in prefs
Design the datasets
Go into prefs and copy the contents of the connection string box
Change the ConnectionString entry from a "Application Scope" "(Connection String)" to a "User scope" "System.String"
Paste the connection string info back into the box (it becomes xml, paste over it)
Now, you can, BEFORE YOU DO ANY DATA ACCESS, change the connection string in code. This is also good to put db password in code..

Do note if you ever have to do anything, and i mean ANYTHING, other than look at a dataset, you *MUST* revert the ConnectionString entry in prefs to a App Scope (Conn Str) type first..
If you dont, and you forget, your datasets may become corrupted and youll need to return here for my assistance sorting them out. Its relatively simple xml changes with a text editor, but hopefully you wont encounter them.
If you do, youll know because the DS designer will start saying "Object ref not set" and warnings about custom tools failing will appear :D:D
 
The dataset uses the connection string it finds in the application preferences to determine which db to connect to. It manages the connections for you and you have no control over that..
This is not entirely so as the sample application I have referenced above shows.
The application uses partial classes to extend the TableAdapter. A SqlConnectionStringBuilder is used in the extended TableAdapter to alter the connectionstring. Here's the method used to do so:
VB.NET:
Public Sub AttachDB1()

    If m_connection Is Nothing Then

        m_connection = New SqlConnection()
        InitConnection()

    Else
        m_connection.Close()
    End If
    Dim execPath As String = _
      Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()(0).FullyQualifiedName)

    Dim newString As SqlConnectionStringBuilder = New SqlConnectionStringBuilder()
    newString.IntegratedSecurity = True
    newString.DataSource = m_connection.DataSource
    newString.AttachDBFilename = execPath & "\Database1\PerfTest.mdf"

    m_connection.ConnectionString = newString.ConnectionString


End Sub
 
nice! dread the day that I'm asked to modify the 225 tableadapters in a certain program, to support this.. for now, the prefs connstring hack is much easier, though with its pitfalls
 
This seems so much harder than how I was able to do it in VS2003!!!!

When you say "do anything" I assume you mean Insert, Update, Delete?
Although my apps do not allow users to delete any data (was a spec requirement I was given) I still need them to be able to Select, Update and Insert.

I did look at the sample database Paszt put me onto, but in all honesty it made me even more confused.

All I want to do is have a simple form presented to the user to select a site - in my case UK, Australia or Thailand (radio boxes) and then when OK is pressed, dependant on the radio box checked, the connection string for the application is then set for the whole project (again, 3 SQL databases - UK, Aus, Thai - all same layout, columns etc etc, just data seperated for each location).

I haven't really played around in XML yet myself, so still a little confused on the whole matter unfortunately.

Thanks for the help so far, much appriciated.
Luke
 
When you say "do anything" I assume you mean Insert, Update, Delete?
No, i mean you, the programmer, at design time, attempts to change ANYTHING about the design of the dataset. As soon as you do this, it will fall over. Its a design time constraint because the designer expects to find a string object that is declared to be a (Connection String).

The main app doesnt care, because the generated code ToString()s it to
use it..

So, its the design tool that falls over wriitng the auto-code.. not the main app

All I want to do is have a simple form presented to the user to select a site - in my case UK, Australia or Thailand (radio boxes) and then when OK is pressed, dependant on the radio box checked, the connection string for the application is then set for the whole project (again, 3 SQL databases - UK, Aus, Thai - all same layout, columns etc etc, just data seperated for each location).

OK, heres a recap:

The DataSet designer expects to find an entry of type (Connection String) in the Settings.

This is just a normal boring string, but so the deisgner knows its a connection string, it has to be set to type (Connection String)

Without this, the designer cant connect the db, read the schema etc and hence it cant write the autogen code.

When its written the code, the code just uses this like any other string

The kicker is.. Settings of type (Connection String) as Application scope, meaning you can only edit them at design time

You want to edit yours at runtime, so you must change it to normal bornign string, and change the scope to user.

As soon as you do his, the designer tools will fail to find the the conn string, and fall over, so make sure youre DONE with the need to use the designer tool in that dataset! Or, be diligent about swapping them


Now you have a User Scope string, you can edit it at program launch:

VB.NET:
If radioAsia.Checked Then
  My.Settings.ConnectionString = "u=user;p=pass;host=whatever;provider=lame db driver"
Else
 ..

I haven't really played around in XML yet myself, so still a little confused on the whole matter unfortunately.
You only need to play round with XML if the designer tool crashes and shafts up your dataset :D
Its an easy, but tedious fix when youre as forgetful as I am

-

Try it in a new project. Make a dataset, conenct the db, it makes an entry in Settings for you, add one table etc.. Save the dataset and close it.
Now go into settings, and change the (Connection String) to string,a nd the scope to user. Edit out the xml guff that has appeared in the box.
Put a line of code in that re-directs the connection string to something else. Run the app - connects to new db!
Now go back to your dataset and edit the table.. It'll break as soon as you try..

So now you know a) how its done, b) how to break it.. hopefully oyu can avoid b) :)
 
Its easily done.. I do it often..

Revert the connection string setting back by choosing "(Connection string)" from the type - it will automatically become an application scope entity, and the text in the box should be automatically taken to be the connection string (and promoted to xml without editing)

Sometimes this is all that is needed.. close all open windows showing dataset designs, dataset code or dataset errors and attempt to reopen them (dont save changes)

If that doesnt work..

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


look for this node:
VB.NET:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]DataSource[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#ff0000]DefaultConnectionIndex[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]1[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#ff0000]FunctionsComponentName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]QueriesTableAdapter[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#ff0000]Modifier[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]AutoLayout, AnsiClass, Class, Public[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#ff0000]SchemaSerializationMode[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]IncludeSchema[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#ff0000]xmlns[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]urn:schemas-microsoft-com:xml-msdatasource[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]Connections[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][B]<[/B][/COLOR][/SIZE][B][SIZE=2][COLOR=#a31515]Connection[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]AppSettingsObjectName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MySettings[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]AppSettingsPropertyName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ConnectionString[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]IsAppSettingsProperty[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]Modifier[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Assembly[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]N[/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#ff0000]ame[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ConnectionString (MySettings)[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]PropertyReference[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ApplicationSettings.WindowsApplication1.My.MySettings.GlobalReference.Default.ConnectionString[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]Provider[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]System.Data.OracleClient[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B][SIZE=2][COLOR=#0000ff][B]>[/B][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]Connection[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]Connection[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]AppSettings[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]ObjectName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MySettings[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]AppSettingsPropertyName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ConnectionString1[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]ConnectionStringObject[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]IsAppSettingsProperty[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]Modifier[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Assembly[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]Name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ConnectionString1 (MySettings)[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]PropertyReference[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ApplicationSettings.WindowsApplication1.My.MySettings.GlobalReference.Default.ConnectionString1[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]Provider[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]System.Data.OracleClient[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]Connection[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]Connections[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[/COLOR][/SIZE]

It may contain multiple entries, with some indexer pointing the designer to one of them, like we see above.

In bold is my original Connection String.. im going to reactivate it by:

copy and paste the
ConnectionStringObject=""
attribute into it

Set the DefaultConnectionIndex="1" to DefaultConnectionIndex="0"


Additionally, if any of the tableadapters have changed connection string, youll need to find it and revert it..
The XML fragment looks like:
VB.NET:
[SIZE=2][SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]TableAdapter[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]BaseClass[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]System.ComponentModel.Component[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]DataAccessorModifier[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]AutoLayout, AnsiClass, Class, Public[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]DataAccessorName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]APARAN_LOGTableAdapter[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]GeneratorDataComponentClassName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]APARAN_LOGTableAdapter[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]Name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]APARAN_LOG[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE]
[SIZE=2][COLOR=#ff0000]UserDataComponentName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]APARAN_LOGTableAdapter[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#a31515]MainSource[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff][B]<[/B][/COLOR][/SIZE][B][SIZE=2][COLOR=#a31515]DbSource[/COLOR][/SIZE][U][I][SIZE=2][COLOR=#ff0000]ConnectionRef[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ConnectionString (MySettings)[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/I][/U][/B]
[B][SIZE=2][COLOR=#ff0000]DbObjectName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]GTP.APARAN_LOG[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]DbObjectType[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Table[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]FillMethodModifier[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]FillMethodName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Fill[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]GenerateMethods[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Both[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]GenerateShortCommands[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]GeneratorGetMethodName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]GetData[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]GeneratorSourceName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Fill[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]GetMethodModifier[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]GetMethodName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]GetData[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]QueryType[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Rowset[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]ScalarCallRetval[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]System.Object, mscorlib, Version=2.0.0.0, [/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#0000ff]Culture=neutral, PublicKeyToken=b77a5c561934e089[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]UseOptimisticConcurrency[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]UserGetMethodName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]GetData[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B]
[B][SIZE=2][COLOR=#ff0000]UserSourceName[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Fill[/COLOR][/SIZE][SIZE=2][COLOR=#000000]"[/COLOR][/SIZE][/B][SIZE=2][COLOR=#0000ff][B]>[/B][/COLOR][/SIZE]
[/SIZE]


ConnectionRef can become changed, if you play with the dataset too much.. set it back to whatever appears in the Name=".." bit at the start.


For additional targeted help with your file, youll have topost it - it may require some, all or none of these changes. I;d also appreciate a screenshot of the error
 
OK going to work on that first thing in the morning.

here's a screenshot of the error - so far I have only tried to add a query to the DWR_Revision table - I have done nothing with the other tables (so hopefully less fiddling needs to be done).

Thanks for the long and painful reply :) I shall let you know how I get on tomorrow (9am UK time that is...)
 

Attachments

  • error.jpg
    error.jpg
    101.6 KB · Views: 98
That should be easy enough to sort simply by closing the DS designer, no save changes, reinstate the connection string to its former glory in the app settings, and try again.

Check the connections section of the xml for duplicates, though I dont think there will be any for now..
 
EDITED - thought it was OK but it isn't

OK, the last post kind of worked...
I can edit and add to the dataset(s) fine now, but the problem is when the program is run - when it goes to initialise the connection, the following line fails in settings.designer.vb

VB.NET:
[SIZE=2]<[/SIZE][SIZE=2][COLOR=#0000ff]Global[/COLOR][/SIZE][SIZE=2].System.Configuration.ApplicationScopedSettingAttribute(), _[/SIZE]
[SIZE=2][COLOR=#0000ff]Global[/COLOR][/SIZE][SIZE=2].System.Diagnostics.DebuggerNonUserCodeAttribute(), _[/SIZE]
[SIZE=2][COLOR=#0000ff]Global[/COLOR][/SIZE][SIZE=2].System.Configuration.SpecialSettingAttribute([/SIZE][SIZE=2][COLOR=#0000ff]Global[/COLOR][/SIZE][SIZE=2].System.Configuration.SpecialSetting.ConnectionString), _[/SIZE]
[SIZE=2][COLOR=#0000ff]Global[/COLOR][/SIZE][SIZE=2].System.Configuration.DefaultSettingValueAttribute([/SIZE][SIZE=2][COLOR=#a31515]"Data Source=UK-BAN-APP1;Initial Catalog=SalesNPD_UK;Integrated Security=True"[/COLOR][/SIZE][SIZE=2])> _[/SIZE]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]ReadOnly[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Property[/COLOR][/SIZE][SIZE=2] SalesNPDConnectionString() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Get[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#a31515]"SalesNPDConnectionString"[/COLOR][/SIZE][SIZE=2]),[/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2]) [B]<-------- Configuration system failed to initialize, check the InnerException property[/B][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Get[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Property[/COLOR][/SIZE]

When I check the InnerException property, I get
{"Unrecognized configuration section userSettings. (C:\Documents and Settings\lukea\Local Settings\Application Data\Company\SalesNPD.vshost.exe_Url_3htybkkupvnlcfky2h5sqyjxohhs3jgr\4.0.0.0\user.config line 5)"}

Just checking through for duplicates as you suggested earlier...

EDIT AGAIN
Cant see any duplicates in the XML file

The problem only happens in debug (F5), when in release (Ctrl+F5) the program works OK...
 
Last edited:
Back
Top