|
-
December 14th, 1999, 10:49 AM
#1
ADO Data Controls/Connect String
I'm pretty new to VB programming, so I hope this isn't a totally stupid question!
Anyways, I am writing an application to a SQL Server database and have created a login screen to get the username and password for the database. I use the username and password to create a connection string and placed it in the variable strConnectString. The question is: how do I use this variable strConnectString in an ADO Data Control? I have tried placing it in the properties for the ADO Data Control but it doesn't work. I figure I'll have to put in some area of code, but where? I don't want to have to hard code the username and password in the ADO Data Control properties.
Any help most gratefully appreciated!
Bud
-
December 14th, 1999, 11:20 AM
#2
Re: ADO Data Controls/Connect String
here is a sample
Dim youruid as string
Dim yourpwd as string
youruid = ' get this from a dialog
yourpwd = ' get this from a dialog
Adodc1.ConnectionString = "DSN=yourDSNgoesHere;uid=" & youruid & ";PWD=" & yourpwd & ";database=yourDatabase"
Adodc1.RecordSource = "select name from sysobjects" ' your recordsource
Adodc1.Refresh
place this code e.g. in a command buttonclick event.
I did NOT set any properties for the data control at runtime.
tested in nt4, vb6, sql 6.5
-
December 14th, 1999, 09:17 PM
#3
Re: ADO Data Controls/Connect String
Lothar,
That was exactly what I needed! I placed the code in the Form_Load() subroutine of the form I had the ADO Data Control in and it worked perfectly.
Many thanks,
Bud
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|