Home > Ask the Microsoft .Net Development Experts > Visual Basic .NET Questions & Answers > Give me an ODBC connect, with SQL authentication
Ask The Win Development Expert: Questions & Answers
EMAIL THIS

Give me an ODBC connect, with SQL authentication

Daniel Cazzulino EXPERT RESPONSE FROM: Daniel Cazzulino

Pose a Question
Other Win Development Categories
Meet all Win Development Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 23 March 2005
I must open an ODBC connection to a DB and must use a connection that looks like this: "DSN=myDSNname". The user must be able to setup SQL Authentication on the DSN and use it to connect. I am getting 28000 error saying that login failed because I do not have a trusted connection. Can you tell me what I am doing wrong? It works if I set up the DSN to use NT authentication, but it will not accept the SQL authentication. ?R.S.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Visual Basic .NET
Access VB .NET Windows control on client side
Drop down list server control creates error message
Converting floating values to byte form
Datagrid issue: 'onselection' is not populating
Read data from parallel port
What is the use of these constructors?
Converting EXE-files to VB components
Generating classes like we did in VB6
Manipulating text through VB.NET
Converting Windows applications to VB .NET

SQL Server and .NET development
Microsoft releases new CTP of Oslo SDK
Perpetuum unveils database synchronizer for .NET 2.0
The CTE, the hierarchical query and SQL Server 2005
SQL Server 2005 recursive functions and the CTE
SQL Examiner Suite synchronizes data schema, sets
Book excerpt: ADO.NET and SQL Server 2005
DataDirect database drivers now support MySQL
Top .NET tips of 2007 (so far)
Addressing common SQL Server questions
Book Excerpt: The .NET Framework and SQL Server 2005

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


When you get these results, it is usually due to the way SQL Server is installed and configured to work with authentication. By default, it will allow only integrated Windows authentication. In order to enable SQL authentication, you must open the SQL Server Enterprise Manager, right-click on the SQL server machine node, and setup mixed mode authentication in the Security section.

Alternatively, you can modify the registry to change the setting easily by modifying the value of the LoginMode entry under MSSQLServer key. These will be located in different places depending on your installation, but usually it will be in HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\LoginMode.

The value should be a REG_DWORD with the value 2. If you save the following script to a file with a .vbs extension, it will be just a matter of double-clicking it on the target machine:

' Changes the login mode of MSDE/SQL Server
Option Explicit
Dim shell
Set shell = CreateObject("WScript.Shell")
Rem Write For default SDK tutorials installation.
shell.RegWrite "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\NetSDK\MSSQLServer\LoginMode", &H2, "REG_DWORD"
Rem Write For standalone MSDE installation (from asp.net site) or full SQL Server setups.
shell.RegWrite "HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\LoginMode", &H2, "REG_DWORD"




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Windows Development - White Papers, News and Expert Advice
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts