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.
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 <vineet.deod...@gmail.com> 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.
"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 <vineet.deod...@gmail.com> 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 <vineet.deod...@gmail.com> 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 -
ok, but I still think using sessions is much more effective :P. I used to code cms systems in PHP. User logged in (or sent some information), those were processed and saved into sessions. It is simple, fast and quite secured.
> "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 <vineet.deod...@gmail.com> 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 <vineet.deod...@gmail.com> 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 <http://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 <http://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 -
> 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 <vineet.deod...@gmail.com> 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 <http://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 <http://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.
On Fri, Jul 3, 2009 at 12:51 PM, vineet <vineet.deod...@gmail.com> 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.
-- Sincerely, Kira Qian E-mail: kiraq...@gmail.com
Hello Vineet let me know that this is ryt or wrong
1.You want to connect to dynamic Database? 2. You want to Build Connection String Dynamically? 3.You want to access 1st Connection String from app.config file??
On Fri, Jul 3, 2009 at 11:16 AM, Vineet <vineet.deod...@gmail.com> 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 <vineet.deod...@gmail.com> 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.
-- Thanks & Regards Avinash Desai *SAVE Nature SAVE Tree SAVE*
I would agree with you that using sessions is much more effective IF
this is a web application. Since the OP stated that they were using
VB.NET Forms I assumed that the application was a WinForms application
and crafted my response as such. If the OP wants correct information
they must state that they are working with Winforms or webforms.
On Jul 3, 8:23 am, Processor Devil <processor.de...@gmail.com> wrote:
> ok, but I still think using sessions is much more effective :P. I used to
> code cms systems in PHP. User logged in (or sent some information), those
> were processed and saved into sessions. It is simple, fast and quite
> secured.
> > "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 <vineet.deod...@gmail.com> 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 <vineet.deod...@gmail.com> 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 <http://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 <http://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 -
--------------------------------------------------------------------------- ------------------------------------
1) My application is Win Forms application. Not a web app.
2) Conn Strings will be built dynamically.
(In short, each user will login with his/her ID and password to mysql
through VB.NET WinForms, doint some work like adding records, fetching
reports, ets., then logging off.) So connection string will be
different for different users.
3) The reason as to WHY I maintain separate projects for separate
forms---
This is to simplify client-updates. I distribute only .exe files to my
clients.
If there is any bug in my code, I can send only a small .exe file
pertaining to that Form. This way, customer servicing is very easy.
What I Tried after my initial post --
1)Created a DLL project with public string property with user scope in
Preferences--Settings.
2)This DLL is referenced in Login form project.
3) From Login form, this string property is modified to hold user's
connection string.
4) This DLL is referred in all other projects requiring conn string.
.......and this works.......
I hope there will not be any security threat for capturing login info
by any malicious lifeform !!
> --------------------------------------------------------------------------- ------------------------------------
> 3) The reason as to WHY I maintain separate projects for separate
> forms---
> This is to simplify client-updates. I distribute only .exe files to my
> clients.
> If there is any bug in my code, I can send only a small .exe file
> pertaining to that Form. This way, customer servicing is very easy.
This Below Class uses the Master database Connection String and then Connects to the Databse which is Stored in the Global Variable with UserId and Password..
#Region "Private Attributes" Private m_ConnectionString As String Public m_Connection As SqlConnection Private m_Command As SqlCommand Private m_DataAdapter As SqlDataAdapter Private m_CommandBuilder As SqlCommandBuilder Private StrSql As String #End Region
'Constructor Public Sub New() 'In Below Line i have connected to the Master database this is mandatory and after that we can build connectionstring Dynamically as shown below m_ConnectionString = ConfigurationManager.ConnectionStrings("DefaultConnectionStringToMasterData base").ConnectionString
Dim ConnStrBuiler As New SqlConnectionStringBuilder(m_ConnectionString) Dim PrevYearConnStr Builer As New SqlConnectionStringBuilder(m_ConnectionString)
Try If Len(glb_DBName) <= 0 Then m_Connection = New Data.SqlClient.SqlConnection(m_ConnectionString) Else ConnStrBuiler.InitialCatalog = glb_DBName m_Connection = New Data.SqlClient.SqlConnection(ConnStrBuiler.ToString()) End If
m_Command = New Data.SqlClient.SqlCommand m_Command.Connection = m_Connection m_Command.CommandType = CommandType.Text
Catch ex As System.InvalidOperationException MessageBox.Show(ex.Message.ToString)
Catch ex As Exception MessageBox.Show(ex.Message.ToString) End Try End Sub
'And a Test Query for the above code 'Wrote a function which Executes the Query sent as parameter and returns the value
Public Function GetValue(ByVal SQL As String) As Object ' Function will return First-Row First-Column result of executing SQL Query over Access Database If m_Connection.State = ConnectionState.Open Then m_Connection.Close() End If
If SQL.Length <= 0 Then Throw New InvalidExpressionException End If
Dim oObject As Object m_Command.CommandText = SQL m_Command.CommandType = CommandType.Text
Catch ex As System.Data.SqlClient.SqlException ' Closing connection Call CloseConnectionObject() Throw New InvalidExpressionException(ex.Message.ToString) Catch ex As System.InvalidOperationException ' Closing connection Call CloseConnectionObject() Throw New InvalidOperationException(ex.Message.ToString) Catch ex As Exception ' Closing connection Call CloseConnectionObject() Throw New Data.DataException Finally ' Closing connection Call CloseConnectionObject() End Try
End Function
Public Sub CloseConnectionObject()
' Closing connection If m_Connection.State = ConnectionState.Open Then m_Connection.Close() End If If Not IsNothing(m_DataAdapter) Then m_DataAdapter.Dispose() End If If Not IsNothing(m_CommandBuilder) Then m_CommandBuilder.Dispose() End If End Sub
On Fri, Jul 3, 2009 at 10:07 PM, Vineet <vineet.deod...@gmail.com> wrote:
> --------------------------------------------------------------------------- ------------------------------------ > 1) My application is Win Forms application. Not a web app.
> 2) Conn Strings will be built dynamically. > (In short, each user will login with his/her ID and password to mysql > through VB.NET WinForms, doint some work like adding records, fetching > reports, ets., then logging off.) So connection string will be > different for different users.
> 3) The reason as to WHY I maintain separate projects for separate > forms--- > This is to simplify client-updates. I distribute only .exe files to my > clients. > If there is any bug in my code, I can send only a small .exe file > pertaining to that Form. This way, customer servicing is very easy.
> What I Tried after my initial post -- > 1)Created a DLL project with public string property with user scope in > Preferences--Settings. > 2)This DLL is referenced in Login form project. > 3) From Login form, this string property is modified to hold user's > connection string. > 4) This DLL is referred in all other projects requiring conn string.
> .......and this works....... > I hope there will not be any security threat for capturing login info > by any malicious lifeform !!
Dear Avinash,
Thanks for your code.
But I think that I haven't explained my need correctly.
It is like this ----
Users will go to login form(of course, it will be .exe).
User will type MySQL login ID and password and computer name hosting
MySQL.
Login ID & password will be different for each & every user.
If the ID & password are correct, then permission is granted and Main
Form opens.
Otherwise permission is denied.
Therefore, I can't hardcode connection string in app.config as you
say.
===============================================
Cerebrus,
Can you pl. suggest an alternative to this problem?
I resorted to this design considering client updates (one project &
one exe for a particular task).
Any light on how can it threaten the scalability?
> Gosh! That's a horrible solution to a common enough problem. Do you
> realize the scalability implications of this kind of design ?
> On Jul 3, 9:37 pm, Vineet <vineet.deod...@gmail.com> wrote:
> > --------------------------------------------------------------------------- ------------------------------------
> > 3) The reason as to WHY I maintain separate projects for separate
> > forms---
> > This is to simplify client-updates. I distribute only .exe files to my
> > clients.
> > If there is any bug in my code, I can send only a small .exe file
> > pertaining to that Form. This way, customer servicing is very easy.- Hide quoted text -
> ===============================================
> Cerebrus,
> Can you pl. suggest an alternative to this problem?
> I resorted to this design considering client updates (one project &
> one exe for a particular task).
> Any light on how can it threaten the scalability?
> > Gosh! That's a horrible solution to a common enough problem. Do you
> > realize the scalability implications of this kind of design ?
> > On Jul 3, 9:37 pm, Vineet <vineet.deod...@gmail.com> wrote:
> > > --------------------------------------------------------------------------- ------------------------------------
> > > 3) The reason as to WHY I maintain separate projects for separate
> > > forms---
> > > This is to simplify client-updates. I distribute only .exe files to my
> > > clients.
> > > If there is any bug in my code, I can send only a small .exe file
> > > pertaining to that Form. This way, customer servicing is very easy.- Hide quoted text -