dynamic username and password in connection string

adshocker

Well-known member
Joined
Jun 30, 2007
Messages
180
Programming Experience
Beginner
hi,

im using oracle10gxe as my database. i've created 2 users. user1 and user2 for example.

then on my vb.net application, i created a connectionstring using the Add New Datasource Wizard. then on my app.config i can see the username i've placed during the wizard.

however, i need to create a login screen but dont have any idea where to start.

on my login_click button
VB.NET:
My.Settings.Item("ConnectionString") = "My connection string"

but how do i open the connection or how do i test if the username and password are valid?
 
adshocker,

i'm assuming you have a good reason for your users to each have their own credential to log into the db. is this correct?

if not, i would just use 1 credential to connect to the db and have some other mechanism in place to control what they can access/do in the app.
 
Yeah, normally we actually have a table with username and a hashed password and use just one user for the database. THis is because setting up 100 oracle users to ahve all the necessary permissions is a pain in the arse
i thought about doing this but i was having a bit of a problem setting roles and priviledges if i do this since the application will have some users with different roles.
 
adshocker,

i'm assuming you have a good reason for your users to each have their own credential to log into the db. is this correct?
in a way, yes. for example, the application may have a part in which only department A can access... then another part of the app will be accessible to department B.. something like that.
 
btw, here is my code for the Log In button.

VB.NET:
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click
        Dim appString As String = My.Settings.Ora10gXEConnection
        Dim orclBuilder As New OracleConnectionStringBuilder(appString)

        Try
            With orclBuilder
                .UserID = txtUsername.Text
                .Password = txtPassword.Text
                .DataSource = "ORCL"
            End With

            My.Settings.Item("Ora10gXEConnection") = orclBuilder.ConnectionString

            Dim cn As New OracleConnection(My.Settings.Item("Ora10gXEConnection"))
            cn.Open()
            MyForm.Show()
            Me.Hide()
        Catch ex As Exception
            MessageBox(ex.Message)
        End Try
    End Sub

will this be ok?

thanks again.
 
Back
Top