Monday, March 12, 2012

ODBC, VB, SQL Authentication

How do I connect to SQL Server using VB6? I will be setting up the ODBC for
SQL using SQL Authentication. Is there a way that I do not hard code the
username and password in the VB program? I wouldn't like to have login
screen to ask for the user's credentials. ThanksHi NS
You can very well prompt users to key in user name and pwd instead of
hardcoding. Infact it is the best technique to do that.
do not provide username and pwd in the connection string, try to pass
parameters that were entered in the popped up text box.
please let me know if u have any questions
--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"NS" wrote:
> How do I connect to SQL Server using VB6? I will be setting up the ODBC for
> SQL using SQL Authentication. Is there a way that I do not hard code the
> username and password in the VB program? I wouldn't like to have login
> screen to ask for the user's credentials. Thanks|||NS,
I would recommend using Windows Authentication instead of SQL Server
Authentication if that is at all possible - more secure.
HTH
Jerry
"NS" <NS@.discussions.microsoft.com> wrote in message
news:076393DE-4439-4169-87E5-595A545226DC@.microsoft.com...
> How do I connect to SQL Server using VB6? I will be setting up the ODBC
> for
> SQL using SQL Authentication. Is there a way that I do not hard code the
> username and password in the VB program? I wouldn't like to have login
> screen to ask for the user's credentials. Thanks|||I was thinking after setting up the DSN for SQL with SQL Authentication, you
could simply point to the dsn in your visual basic code when connecting to
the database (ADODB.Connection...). I thought one need not provide the user
and password again. So, that isn't true?
"Chandra" wrote:
> Hi NS
> You can very well prompt users to key in user name and pwd instead of
> hardcoding. Infact it is the best technique to do that.
> do not provide username and pwd in the connection string, try to pass
> parameters that were entered in the popped up text box.
> please let me know if u have any questions
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://www.SQLResource.com/
> ---
>
> "NS" wrote:
> > How do I connect to SQL Server using VB6? I will be setting up the ODBC for
> > SQL using SQL Authentication. Is there a way that I do not hard code the
> > username and password in the VB program? I wouldn't like to have login
> > screen to ask for the user's credentials. Thanks|||You can also can force the prompt in code - it's a property
that's exposed for the connection object in ADO.
YourConnection.Properties("Prompt") = adPromptAlways
YourConnection.Open ...etc just specifying driver, server
and database.
-Sue
On Tue, 25 Oct 2005 07:37:12 -0700, "NS"
<NS@.discussions.microsoft.com> wrote:
>How do I connect to SQL Server using VB6? I will be setting up the ODBC for
>SQL using SQL Authentication. Is there a way that I do not hard code the
>username and password in the VB program? I wouldn't like to have login
>screen to ask for the user's credentials. Thanks|||"NS" <NS@.discussions.microsoft.com> wrote in message
news:1E3777C8-3B00-4A83-8C63-7DBD9D3CE30A@.microsoft.com...
> I was thinking after setting up the DSN for SQL with SQL Authentication,
you
> could simply point to the dsn in your visual basic code when connecting to
> the database (ADODB.Connection...). I thought one need not provide the
user
> and password again. So, that isn't true?
Yes, it is true. You need to declare the following in your VB app:
Private Declare Function SQLReadFileDSN Lib "ODBCCP32.DLL" _
(ByVal lpszFileName As String, _
ByVal lpszAppName As String, _
ByVal lpszKeyName As String, _
ByVal lpszString As String, _
ByVal cbString As Long, _
ByRef pcbString As Long) As Long
Lookup the function SQLReadFileDSN in MSDN for examples of how to use it and
what the parameters mean.
> "Chandra" wrote:
> > Hi NS
> >
> > You can very well prompt users to key in user name and pwd instead of
> > hardcoding. Infact it is the best technique to do that.
> >
> > do not provide username and pwd in the connection string, try to pass
> > parameters that were entered in the popped up text box.
> >
> > please let me know if u have any questions
> >
> > --
> > best Regards,
> > Chandra
> > http://chanduas.blogspot.com/
> > http://www.SQLResource.com/
> > ---
> >
> >
> >
> > "NS" wrote:
> >
> > > How do I connect to SQL Server using VB6? I will be setting up the
ODBC for
> > > SQL using SQL Authentication. Is there a way that I do not hard code
the
> > > username and password in the VB program? I wouldn't like to have
login
> > > screen to ask for the user's credentials. Thanks

No comments:

Post a Comment