|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Strongly Typed ConnectionString keeps disappearingI have been using strongly typed Datasets/database connections, it works fine Now, I've added a OpenFileDialog functionality to my program so the user can select the database file. I've added & strCon & to this code (it's a Global variable): Me.conADOConnection.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _ "ocking Mode=1;Data Source=" & strCon & ";Jet OLEDB:Engine Type=5;" & _ "Provider=""Microsoft.Jet.OLEDB.4.0"";........... It works fine for a while, but occasionally this whole command seems to just disappear. It tends to happen if I add a control to my form or make some other big change. If I paste the code back in from another form it works fine (for a while). Why does my connection string keep disappearing?
Show quote
On 27 Apr 2006 08:53:32 -0700, "Aziz" <aziz***@googlemail.com> wrote: Have you placed "Me.conADOConnection.ConnectionString = ..." inside the designer created InitComponent() method? As the>VB 2003, Access 2000 > >I have been using strongly typed Datasets/database connections, it >works fine > >Now, I've added a OpenFileDialog functionality to my program so the >user can select the database file. > >I've added & strCon & to this code (it's a Global variable): > > Me.conADOConnection.ConnectionString = "Jet OLEDB:Global Partial Bulk >Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _ > "ocking Mode=1;Data Source=" & strCon & ";Jet OLEDB:Engine >Type=5;" & _ > "Provider=""Microsoft.Jet.OLEDB.4.0"";........... > >It works fine for a while, but occasionally this whole command seems to >just disappear. It tends to happen if I add a control to my form or >make some other big change. If I paste the code back in from another >form it works fine (for a while). > >Why does my connection string keep disappearing? designer tends to just overwrite this section. If so try moving the connection string into the constructor after InitComponent() and it will be left alone (although the designer may show the connection string as being blank, just ignore that). Aziz,
In addition to Chris, How and where did you put that connectionstring in your code. Normally I expect it in a kind of config, which depends if it is ASPNET or Webform. Cor Show quote "Aziz" <aziz***@googlemail.com> schreef in bericht news:1146153211.964831.87310@t31g2000cwb.googlegroups.com... > VB 2003, Access 2000 > > I have been using strongly typed Datasets/database connections, it > works fine > > Now, I've added a OpenFileDialog functionality to my program so the > user can select the database file. > > I've added & strCon & to this code (it's a Global variable): > > Me.conADOConnection.ConnectionString = "Jet OLEDB:Global Partial Bulk > Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _ > "ocking Mode=1;Data Source=" & strCon & ";Jet OLEDB:Engine > Type=5;" & _ > "Provider=""Microsoft.Jet.OLEDB.4.0"";........... > > It works fine for a while, but occasionally this whole command seems to > just disappear. It tends to happen if I add a control to my form or > make some other big change. If I paste the code back in from another > form it works fine (for a while). > > Why does my connection string keep disappearing? > Thanks Chris, you were right, it was in:
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() But now I put it under "Public Sub New()" below the InitializeComponent() method call and it works fine. I think VS put it in InitializeComponent() automatically. Cor: My connection string is a public variable in a module. Anyway it's working fine now so thanks to both of you. |
|||||||||||||||||||||||