Home All Groups Group Topic Archive Search About

Strongly Typed ConnectionString keeps disappearing

Author
27 Apr 2006 3:53 PM
Aziz
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?

Author
27 Apr 2006 9:18 PM
Chris Chilvers
Show quote
On 27 Apr 2006 08:53:32 -0700, "Aziz" <aziz***@googlemail.com> wrote:

>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?

Have you placed "Me.conADOConnection.ConnectionString = ..." inside the designer created InitComponent() method? As the
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).
Author
28 Apr 2006 5:19 AM
Cor Ligthert [MVP]
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?
>
Author
28 Apr 2006 8:29 AM
Aziz
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.

AddThis Social Bookmark Button