"It will be different for each session (to be entered from login
screen) "  I would think that the connection string would be different
for each user not each session.

Here's one way I can think of doing this (its early here and I may not
be thinking this through in the best way).


I'm not sure why the VB forms are in different projects, but it
doesn't matter for this.  I would recommend creating a DLL (Class
Library project) that both projects would reference.  This DLL would
facilitate communication to and from the database as well as any other
code that you tend to use repeatedly (Its nice to have code in one
location if you need to make a change rather than having identical
code in many locations that requires changing).  Since most of your
connection string remains the same, have it coded inside the a class
in the DLL project. The DLL Project can have an app config that you
can store configurables such as the IP address or server name and the
database name.  Then create a function that builds your connection
string.  The username and password variables come from the login
form.

(Note: the following code was typed in here and is most likely missing
some important syntax - I haven't coded in VB for over a year).

Public String CreateConnectionString(UserName as String, Password as
String)
  Return Server=(from app.config);Database=(from
app.config);Uid=UserName;Pwd=Password;

End Sub




On Jul 2, 11:46 pm, Vineet <[email protected]> wrote:
> This is editing by the author himself: (since google groups doesn't
> have edit facility)
> ============================================
> The VB forms are in different projects. That's why I am wondering how
> to store & retrieve database connection string in app.config
> ---Vineet
> =============================================
> On Jul 3, 9:51 am, vineet <[email protected]> wrote:
>
>
>
> > Dear Friends,
> > May I request for a small help regarding VB-MySQL !
> > I have ERP solution in VFP for medium scale businesses.
> > I am now converting it to VB-MySQL.
> > In this, different users need to login with their ID's.
> > So, the connection string can't be defined while writing code. It will
> > be different for each session (to be entered from login screen)
> > Secondly, there are more that 100 VB.NET forms, each requiring
> > connection string to MySQL.
> > If we store conn string in app.config of a particular form, how other
> > forms can retrieve it ?
> > My query is that, where & how to store the connection string sothat --
> > 1) it will be available to all different VB.NET forms, and
> > 2) connection string to MySQL will be different for every session.
> > You are requested to throw some light on the above-mentioned task.
> > Thanks,
> > Vineet.- Hide quoted text -
>
> - Show quoted text -

Reply via email to