C# - SQLDriverConnect

  • Thread starter Thread starter Dale Magnuson
  • Start date Start date
D

Dale Magnuson

Does anyone know what API I need to include to be able to
use the SQLDriverConnect function with C#? I was given a
code example on how to setup my DSN-less connection and I
keep getting a pop-up dialog box to configure my
connection. I want to use the SQLDriverConnect function
so that I can utilize the SQL_DRIVER_NOPROMPT parameter.

If anyone has any insight to this it would be greatly
appreciated.

Thanks,
Dale
 
Hi Dale,

Do you hard-coded your data source connection string into your application?
If so, in .Net I think you can use System.Data.Odbc.OdbcConnection class
instead.
Also, you can place your connection into the config file to add some
facility.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Dale Magnuson" <[email protected]>
| Sender: "Dale Magnuson" <[email protected]>
| Subject: C# - SQLDriverConnect
| Date: Fri, 26 Sep 2003 06:30:59 -0700
| Lines: 12
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOEMmvqB0Mbm2ocQS66yGg4H3ryJg==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187538
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Does anyone know what API I need to include to be able to
| use the SQLDriverConnect function with C#? I was given a
| code example on how to setup my DSN-less connection and I
| keep getting a pop-up dialog box to configure my
| connection. I want to use the SQLDriverConnect function
| so that I can utilize the SQL_DRIVER_NOPROMPT parameter.
|
| If anyone has any insight to this it would be greatly
| appreciated.
|
| Thanks,
| Dale
|
 
The problem that I am having with
System.Data.Odbc.OdbcConnection is that it doesn't seem to
contain a SQL_DRIVER_NOPROMPT parameter anywhere. The
SQLDriverConnect has an option for this parameter, but I
cannot find one in the ODBC class.

Any suggestions?

-----Original Message-----

Hi Dale,

Do you hard-coded your data source connection string into your application?
If so, in .Net I think you can use
System.Data.Odbc.OdbcConnection class
 
Hi Dale,

For System.Data.Odbc.OdbcConnection class, it encapsulats the ODBC
functions.
It will not prompt the dialog box for connection string, so you can use it.

Btw: for Sql Server version upper 7.0, it is recommended that use ".NET
Framework Data Provider for SQL Server",
it is optimized for Sql Server.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Dale Magnuson" <[email protected]>
| Sender: "Dale Magnuson" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: C# - SQLDriverConnect
| Date: Mon, 29 Sep 2003 05:40:10 -0700
| Lines: 72
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcOGhtJUWcvJN4MbTR+LQVNMTrRx8g==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:187968
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| The problem that I am having with
| System.Data.Odbc.OdbcConnection is that it doesn't seem to
| contain a SQL_DRIVER_NOPROMPT parameter anywhere. The
| SQLDriverConnect has an option for this parameter, but I
| cannot find one in the ODBC class.
|
| Any suggestions?
|
|
| >-----Original Message-----
| >
| >Hi Dale,
| >
| >Do you hard-coded your data source connection string into
| your application?
| >If so, in .Net I think you can use
| System.Data.Odbc.OdbcConnection class
| >instead.
| >Also, you can place your connection into the config file
| to add some
| >facility.
| >
| >Hope this helps,
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Dale Magnuson" <[email protected]>
| >| Sender: "Dale Magnuson" <[email protected]>
| >| Subject: C# - SQLDriverConnect
| >| Date: Fri, 26 Sep 2003 06:30:59 -0700
| >| Lines: 12
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Thread-Index: AcOEMmvqB0Mbm2ocQS66yGg4H3ryJg==
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:187538
| >| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| Does anyone know what API I need to include to be able
| to
| >| use the SQLDriverConnect function with C#? I was given
| a
| >| code example on how to setup my DSN-less connection and
| I
| >| keep getting a pop-up dialog box to configure my
| >| connection. I want to use the SQLDriverConnect
| function
| >| so that I can utilize the SQL_DRIVER_NOPROMPT parameter.
| >|
| >| If anyone has any insight to this it would be greatly
| >| appreciated.
| >|
| >| Thanks,
| >| Dale
| >|
| >
| >.
| >
|
 
Thank you very much for your response - this is good
news. I assume this means that there is something wrong
with my connection string because I keep getting the
dialog box. I am trying to use a driver to connect to a
Tandem NonStop SQL box and I am getting the dialog box
everytime. I haven't found a lot of resources for what
the connection string should look like.

For a workaround I wrote a function to build the DSN in
the registry on the fly - this seems to work fine, but I
don't know if it is the best solution or not.

Thanks again,
Dale
 
Hi Dale,

Just as I original said, the suggested .NET Framework Data Provider for SQL
Server uses its own protocol to communicate with SQL Server. It does not
support the use of an ODBC data source name (DSN) when connecting to SQL
Server because it does not add an ODBC layer.

For System.Data.Odbc, if you do not use the DNS, you can specify the user
id and password in connection string, for more details, please refer to the
link below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemDataOdbcOdbcConnectionClassConnectionStringTopic.asp

Btw: The .NET Framework Data Provider for ODBC is not included in the .NET
Framework version 1.0. If you require the .NET Framework Data Provider for
ODBC and are using the .NET Framework version 1.0, you can download the
.NET Framework Data Provider for ODBC at
http://msdn.microsoft.com/downloads. The namespace for the downloaded .NET
Framework Data Provider for ODBC is Microsoft.Data.Odbc.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Dale Magnuson" <[email protected]>
| Sender: "Dale Magnuson" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: RE: C# - SQLDriverConnect
| Date: Tue, 30 Sep 2003 06:12:41 -0700
| Lines: 149
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcOHVIduMaArTtkKT7urNfAfpXwUwQ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:188191
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Thank you very much for your response - this is good
| news. I assume this means that there is something wrong
| with my connection string because I keep getting the
| dialog box. I am trying to use a driver to connect to a
| Tandem NonStop SQL box and I am getting the dialog box
| everytime. I haven't found a lot of resources for what
| the connection string should look like.
|
| For a workaround I wrote a function to build the DSN in
| the registry on the fly - this seems to work fine, but I
| don't know if it is the best solution or not.
|
| Thanks again,
| Dale
|
|
| >-----Original Message-----
| >
| >Hi Dale,
| >
| >For System.Data.Odbc.OdbcConnection class, it encapsulats
| the ODBC
| >functions.
| >It will not prompt the dialog box for connection string,
| so you can use it.
| >
| >Btw: for Sql Server version upper 7.0, it is recommended
| that use ".NET
| >Framework Data Provider for SQL Server",
| >it is optimized for Sql Server.
| >
| >Best regards,
| >Jeffrey Tan
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Dale Magnuson" <[email protected]>
| >| Sender: "Dale Magnuson" <[email protected]>
| >| References: <[email protected]>
| ><[email protected]>
| >| Subject: RE: C# - SQLDriverConnect
| >| Date: Mon, 29 Sep 2003 05:40:10 -0700
| >| Lines: 72
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| Thread-Index: AcOGhtJUWcvJN4MbTR+LQVNMTrRx8g==
| >| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:187968
| >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >|
| >| The problem that I am having with
| >| System.Data.Odbc.OdbcConnection is that it doesn't seem
| to
| >| contain a SQL_DRIVER_NOPROMPT parameter anywhere. The
| >| SQLDriverConnect has an option for this parameter, but
| I
| >| cannot find one in the ODBC class.
| >|
| >| Any suggestions?
| >|
| >|
| >| >-----Original Message-----
| >| >
| >| >Hi Dale,
| >| >
| >| >Do you hard-coded your data source connection string
| into
| >| your application?
| >| >If so, in .Net I think you can use
| >| System.Data.Odbc.OdbcConnection class
| >| >instead.
| >| >Also, you can place your connection into the config
| file
| >| to add some
| >| >facility.
| >| >
| >| >Hope this helps,
| >| >Best regards,
| >| >Jeffrey Tan
| >| >Microsoft Online Partner Support
| >| >Get Secure! - www.microsoft.com/security
| >| >This posting is provided "as is" with no warranties
| and
| >| confers no rights.
| >| >
| >| >--------------------
| >| >| Content-Class: urn:content-classes:message
| >| >| From: "Dale Magnuson" <[email protected]>
| >| >| Sender: "Dale Magnuson" <[email protected]>
| >| >| Subject: C# - SQLDriverConnect
| >| >| Date: Fri, 26 Sep 2003 06:30:59 -0700
| >| >| Lines: 12
| >| >| Message-ID: <[email protected]>
| >| >| MIME-Version: 1.0
| >| >| Content-Type: text/plain;
| >| >| charset="iso-8859-1"
| >| >| Content-Transfer-Encoding: 7bit
| >| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| >| X-MIMEOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| >| Thread-Index: AcOEMmvqB0Mbm2ocQS66yGg4H3ryJg==
| >| >| Newsgroups: microsoft.public.dotnet.languages.csharp
| >| >| Path: cpmsftngxa06.phx.gbl
| >| >| Xref: cpmsftngxa06.phx.gbl
| >| microsoft.public.dotnet.languages.csharp:187538
| >| >| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| >| >| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| >| >|
| >| >| Does anyone know what API I need to include to be
| able
| >| to
| >| >| use the SQLDriverConnect function with C#? I was
| given
| >| a
| >| >| code example on how to setup my DSN-less connection
| and
| >| I
| >| >| keep getting a pop-up dialog box to configure my
| >| >| connection. I want to use the SQLDriverConnect
| >| function
| >| >| so that I can utilize the SQL_DRIVER_NOPROMPT
| parameter.
| >| >|
| >| >| If anyone has any insight to this it would be
| greatly
| >| >| appreciated.
| >| >|
| >| >| Thanks,
| >| >| Dale
| >| >|
| >| >
| >| >.
| >| >
| >|
| >
| >.
| >
|
 
Back
Top