Multimobile Development: Building Applications for any Smartphone
ODBC DSN
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.odbcnet.


Jeff
GOOD ANSWER
I am trying to connect to a System DSN using the ODBC .NET
provider. When I set the connection string to "DSN=xxx";
I get a data source not found error.

I do not want to use a Driver= keyword, but when I do use
one like "Driver={SQL Server};DSN=Info;" I get a SQL
Driver error that DSN was not specified.

Is there some problem with the DSN keyword?

Thanks,
Jeff
Reply to this message...
Vote that this is a GOOD answer... (5 votes from other users already)
 
 
    
Steven Bras [MS]
GOOD ANSWER
If you are using the driver keyword, you need not specify (nor should you
specify) a DSN as well. All the information can be contained in the
connection string such as server, database, user id and password if
applicable.

However, you don't specify whether you're using the ODBC.Net provider in
ASP.Net or a Windows application; in either case (more commonly with
ASP.Net) this error is due to the fact that the DSN definition in the
registry cannot be accessed, due to restricted permissions on that hive.

I would start there and check the permissions on the following two keys
(depending on whether your DSN is a user DSN or a system one):

HKEY_LOCAL_MACHINE\SOFTWARE\ODBC and its subkeys
and
HKEY_CURRENT_USER\Software\ODBC and its subkeys

Make sure they allow Read access, at minimum to the following groups:

HKLM: Admins, Creator Owner, Power Users, System, and Users
HKCU: Administrators, Restricted, and System

Hope this helps!

Steven Bras, MCSD
Microsoft Developer Support/Visual Basic WebData

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Peter Chong
GOOD ANSWER
Hi, Steven
I have dsn like dsn=dsn01;user=sqldbo;pwd=sqlpwd table1
can you share some sample connection asp.net code?
TIA, PeterC
Click here to reveal e-mail address (Steven Bras [MS]) wrote in message news:<ddntLY9FCHA.1336@cpmsftngxa08>...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Dan Kirby
GOOD ANSWER
Hi,

You mentioned:

[Original message clipped]

Are you receiving the "datasource not found" error as well or some other
ODBC error. In your connection string you show "user=". This should be
changed to "UID=". Normally you wouldn't be getting the "datasource not
found" error but some error about "login failed".

To open up the connection you would have something like:

OdbcConnection con = new
OdbcConnection("DSN=mysystemDSN;UID=sa;PWD=somepassword;");
con.Open();

Dan Kirby
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
[Original message clipped]

.net!newsfeed.fjserv.net!newsfeed1.cidera.com!Cidera!ps01-sjc1!news.webusene
t.com!sn-xit-05!sn-xit-08!supernews.com!postnews1.google.com!not-for-mail
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Dietmar Kurok
GOOD ANSWER
Hello!
I've got the same problem (W2K Professional).
Steven, you mentioned the following:
[Original message clipped]

key.
Is it the user ASPNET who must have read access to the mentioned keys
(direct or by the groups he belongs to)?

""Dan Kirby"" <Click here to reveal e-mail address> schrieb im Newsbeitrag
news:kGBXXumHCHA.1956@cpmsftngxa07...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (2 votes from other users already)
 
 
    
Steven Bras [MS]
GOOD ANSWER
On Windows 2000 and NT, use regedt32.exe; under XP, the registry permission
settings are included in regedit.exe.

Hope this helps!

Steven Bras, MCSD
Microsoft Developer Support/Visual Basic WebData

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
    
Steven Bras [MS]
GOOD ANSWER
To use an ODBC DSN, you must use the ODBC managed provider. This does not
ship with the .Net Framework, but can be downloaded from:

http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?ur
l=/MSDN-FILES/027/001/668/msdncompositedoc.xml&frame=true

First, set a reference in your project to microsoft.data.odbc.dll; To open
a connection to an odbc data source, you would use code similar to:

Imports Microsoft.Data.ODBC
' Class declaration follows
Dim oCn as New ODBCConnection("DSN=MyDSN;UID=YourID;PWD=YourPwd;")

The rest is quite similar to the SQL and the OLEDB clients; open an OLEDB
Data Adapter and fill a DataSet object, or use the ODBCDataReader to read
data directly.

Hope this helps!

Steven Bras, MCSD
Microsoft Developer Support/Visual Basic WebData

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer... (3 votes from other users already)
 
 
 
System.Data.DataSet
System.Data.Odbc.OdbcConnection




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734