[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

(Peter Chong)

6/28/2002 8:00:00 AM

Hi, Steven
I have dsn like dsn=dsn01;user=sqldbo;pwd=sqlpwd table1
can you share some sample connection asp.net code?
TIA, PeterC
stevenbr@online.microsoft.com (Steven Bras [MS]) wrote in message news:<ddntLY9FCHA.1336@cpmsftngxa08>...
> 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.co....
4 Answers

(Dan Kirby)

6/28/2002 7:47:00 AM

0

Hi,

You mentioned:

>>I have dsn like dsn=dsn01;user=sqldbo;pwd=sqlpwd table1
>>>can you share some sample connection asp.net code?

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.

--------------------
>>From: pchq45@hotmail.com (Peter Chong)
>>Newsgroups: microsoft.public.dotnet.framework.odbcnet
>>Subject: Re: ODBC DSN
>>Date: 27 Jun 2002 22:14:44 -0700
>>Organization: http://groups.g...
>>Lines: 37
>>Message-ID: <444b2a14.0206272114.398fb2a1@posting.google.com>
>>References: <e9c201c217c1$81dd82e0$36ef2ecf@tkmsftngxa12>
<ddntLY9FCHA.1336@cpmsftngxa08>
>>NNTP-Posting-Host: 68.66.78.84
>>Content-Type: text/plain; charset=ISO-8859-1
>>Content-Transfer-Encoding: 8bit
>>X-Trace: posting.google.com 1025241285 18965 127.0.0.1 (28 Jun 2002
05:14:45 GMT)
>>X-Complaints-To: groups-abuse@google.com
>>NNTP-Posting-Date: 28 Jun 2002 05:14:45 GMT
>>Path:
cpmsftngxa07!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de!newsfeed.icl
.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
>>Xref: cpmsftngxa07 microsoft.public.dotnet.framework.odbcnet:1392
>>X-Tomcat-NG: microsoft.public.dotnet.framework.odbcnet
>>
>>Hi, Steven
>>I have dsn like dsn=dsn01;user=sqldbo;pwd=sqlpwd table1
>>can you share some sample connection asp.net code?
>>TIA, PeterC
>>stevenbr@online.microsoft.com (Steven Bras [MS]) wrote in message
news:<ddntLY9FCHA.1336@cpmsftngxa08>...
>>> 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.co....
>>

Dietmar Kurok

7/11/2002 8:57:00 PM

0

Hello!
I've got the same problem (W2K Professional).
Steven, you mentioned the following:
> >>> 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
> >>>
How can I check this? Regedit doesn't tell me who has the right to read a
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"" <dank@online.microsoft.com> schrieb im Newsbeitrag
news:kGBXXumHCHA.1956@cpmsftngxa07...
> Hi,
>
> You mentioned:
>
> >>I have dsn like dsn=dsn01;user=sqldbo;pwd=sqlpwd table1
> >>>can you share some sample connection asp.net code?
>
> 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.
>
> --------------------
> >>From: pchq45@hotmail.com (Peter Chong)
> >>Newsgroups: microsoft.public.dotnet.framework.odbcnet
> >>Subject: Re: ODBC DSN
> >>Date: 27 Jun 2002 22:14:44 -0700
> >>Organization: http://groups.g...
> >>Lines: 37
> >>Message-ID: <444b2a14.0206272114.398fb2a1@posting.google.com>
> >>References: <e9c201c217c1$81dd82e0$36ef2ecf@tkmsftngxa12>
> <ddntLY9FCHA.1336@cpmsftngxa08>
> >>NNTP-Posting-Host: 68.66.78.84
> >>Content-Type: text/plain; charset=ISO-8859-1
> >>Content-Transfer-Encoding: 8bit
> >>X-Trace: posting.google.com 1025241285 18965 127.0.0.1 (28 Jun 2002
> 05:14:45 GMT)
> >>X-Complaints-To: groups-abuse@google.com
> >>NNTP-Posting-Date: 28 Jun 2002 05:14:45 GMT
> >>Path:
>
cpmsftngxa07!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de!newsfeed.icl
>
.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
> >>Xref: cpmsftngxa07 microsoft.public.dotnet.framework.odbcnet:1392
> >>X-Tomcat-NG: microsoft.public.dotnet.framework.odbcnet
> >>
> >>Hi, Steven
> >>I have dsn like dsn=dsn01;user=sqldbo;pwd=sqlpwd table1
> >>can you share some sample connection asp.net code?
> >>TIA, PeterC
> >>stevenbr@online.microsoft.com (Steven Bras [MS]) wrote in message
> news:<ddntLY9FCHA.1336@cpmsftngxa08>...
> >>> 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.co....
> >>
>


(Steven Bras [MS])

7/11/2002 10:05:00 PM

0

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.co....

(Steven Bras [MS])

7/11/2002 10:10:00 PM

0

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/sam...
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.co....