prinsbj
asked on
How to build a loginform in vb.net with a addtional function to select a database?
Can somebody help me with a loginform that has a extra function to select a database.
So i want that user can login in the production db or in the testdb.
I use sql 2005 en vb.net in Visual studio 2008
Thanks for your reactions
Bart
So i want that user can login in the production db or in the testdb.
I use sql 2005 en vb.net in Visual studio 2008
Thanks for your reactions
Bart
Note. Is important to Change the MainForm.Text (Caption) to indicate Test Connection.
This is used for Test the program, but also for formation.
This is used for Test the program, but also for formation.
ASKER
oke but how can i set the parameters?
And if i use a auto update program to install
Thank
And if i use a auto update program to install
Thank
On this Sample, I use OleDb.
I connect to Oracle Production database when Environment.GetCommandLine Args are empty.
I Use Parameter values as a Path to a Ms Access Database as Test Database.
DbTxt variable is used to show current Database on MainForm.
I connect to Oracle Production database when Environment.GetCommandLine
I Use Parameter values as a Path to a Ms Access Database as Test Database.
DbTxt variable is used to show current Database on MainForm.
Public Function GetDbConnection() As OleDbConnection
Dim s = Environment.GetCommandLineArgs, CnStr As String, cn As OleDbConnection = Nothing
Dim LocalDb = s.Length > 1
If LocalDb Then
DbTxt = s(1)
CnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & DbTxt
Else
DbTxt = "Oracle"
CnStr = My.Settings.CnStr & Decode(My.Settings.Pwd)
End If
Try
cn = New OleDbConnection(CnStr)
cn.Open()
If LocalDb Then
IsReten = True
IsJt = True
Else
Dim cmd As New OleDbCommand("Select Prv from Priv Where NtUsr=?", cn)
cmd.Parameters.AddWithValue(Nothing, Environment.UserName.ToUpper)
Dim Prv = cmd.ExecuteScalar
If Prv IsNot DBNull.Value Then
Dim v = CInt(Prv)
If (v And PrivPrj.Adm) > 0 Then IsAdm = True
If IsAdm OrElse (v And PrivPrj.Reten) > 0 Then IsReten = True
If IsReten OrElse (v And PrivPrj.JT) > 0 Then IsJt = True
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Conexión Base de datos")
cn = Nothing
End Try
Return cn
End Function
Note.:
You can drag a Mdb File from Explorer over Application Icon.
Then You are usign application with mdb file name as argument.
You can drag a Mdb File from Explorer over Application Icon.
Then You are usign application with mdb file name as argument.
ASKER
Thank you for sending this script,
I see you us decode for your password how can i us that also?
I see you us decode for your password how can i us that also?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello x77,
When i'm back home i'll test it and let you know.
Thank
When i'm back home i'll test it and let you know.
Thank
One option would be to use a setting in the app.config file and use two connection strings. Depending on this setting(RunInTestMode), you can use either Live or Test connection string.
ASKER
Hello X77!
It works great.
Thank you.
It works great.
Thank you.
Normal User uses a icon to access application.
I Inspect CommandLine when Programa Start and change Connection String if CommandLine has Apropiate Parameters.
I can creata an alternate Icon to Access to Test and change Name to "Test MyProgram"