insert credentials into connection string?

dsk96m

Well-known member
Joined
Jan 11, 2013
Messages
173
Programming Experience
1-3
In my application i have added a datasource (dataset) called ORAP_DS. When asked if i should save the credentials in the connection string I said no. This is because each user will have a different username and password. So the application opens to a login form. The user enters their username and pw. How do I insert that into the connection string?

One thing I think i saw was if I made the connection string like this:
DATA SOURCE=ORAP;USER ID={username};PASSWORD={pwd};Persist Security Info=False
Then in my login for on ok click i have:
VB.NET:
        'Build ConnectionString based on user login details
        Dim con As String = ConfigurationManager.ConnectionStrings("ASF.My.MySettings.ORA_Conn").ConnectionString
        con = con.Replace("{username}", Trim$(UsernameTextBox.Text))
        con = con.Replace("{pwd}", PasswordTextBox.Text)

This is where I am at now. How do I use have the ORAP_DS (dataset) use this connection string instead of the connection string that is in settings?
 
Ok, i have this now:
VB.NET:
        'Build ConnectionString based on user login details
        Dim constr As String = ConfigurationManager.ConnectionStrings("ASF.My.MySettings.ORA_Conn").ConnectionString
        constr = constr.Replace("{username}", Trim$(UsernameTextBox.Text))
        constr = constr.Replace("{pwd}", PasswordTextBox.Text)

        Dim con As New ora.OracleConnection
        con.ConnectionString = constr
        con.Open()

So i believe i am connected. Did not get an error, but when I try to try something like:
Me.TFSETEMPLTableAdapter.Fill(Me.ORAP_DS.TFSETEMPL)

I get ORA-1017: invalid username/password; logon denied. I am assuming because it isnt using the connection above, but the one in my settings.
 
I cant change the setting in code because it is read only. So how to I associate the constructed connection string with the dataset.xsd in my solution
 
Back
Top