PC Review


Reply
Thread Tools Rate Thread

Connect to remote xls via odbc and dsn

 
 
Karl
Guest
Posts: n/a
 
      12th Jul 2005
We have an application which checks users against a regularly updated
xls spreadsheet from our client. We need to be able to connect to this
xls on our remote server and so have decided to use a DSN. When I used
VB.Net to test the connection there were no errors, however when I use
asp.net to get the connection I do get one.

I cant use a relative path to the file as is normal in a
connectionstring as the environment is a shared one.

The code is shown below. Please help.

VB.NET CODE:
Try
Dim oEConn As New OdbcConnection
oEConn.ConnectionString = "DSN=members_bmf"
oEConn.Open()
Catch ex As Exception
MsgBox(ex.ToString)
End Try

ASP.NET Code

Try
Dim oEConn As New OdbcConnection
oEConn.ConnectionString = "DSN=members_bmf"
oEConn.Open()
Catch ex As Exception
'errMessage is an asp.netlabel
errMessage.text =ex.ToString
End Try


Here is the error
System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified at
System.Data.Odbc.OdbcConnection.Open() at
ASP.bmf_validate_bmf_member_ascx.CheckMembership(Object sender,
EventArgs e) in \\TLBFS01\development\Projects\Tradecounter\Portal
Development\TCCPortal
Development\modules\bmf_validate_bmf_member.ascx:line 41

 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      12th Jul 2005
On 12 Jul 2005 04:10:15 -0700, "Karl" <(E-Mail Removed)> wrote:

¤ We have an application which checks users against a regularly updated
¤ xls spreadsheet from our client. We need to be able to connect to this
¤ xls on our remote server and so have decided to use a DSN. When I used
¤ VB.Net to test the connection there were no errors, however when I use
¤ asp.net to get the connection I do get one.
¤
¤ I cant use a relative path to the file as is normal in a
¤ connectionstring as the environment is a shared one.
¤
¤ The code is shown below. Please help.
¤
¤ VB.NET CODE:
¤ Try
¤ Dim oEConn As New OdbcConnection
¤ oEConn.ConnectionString = "DSN=members_bmf"
¤ oEConn.Open()
¤ Catch ex As Exception
¤ MsgBox(ex.ToString)
¤ End Try
¤
¤ ASP.NET Code
¤
¤ Try
¤ Dim oEConn As New OdbcConnection
¤ oEConn.ConnectionString = "DSN=members_bmf"
¤ oEConn.Open()
¤ Catch ex As Exception
¤ 'errMessage is an asp.netlabel
¤ errMessage.text =ex.ToString
¤ End Try
¤
¤
¤ Here is the error
¤ System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver
¤ Manager] Data source name not found and no default driver specified at
¤ System.Data.Odbc.OdbcConnection.Open() at
¤ ASP.bmf_validate_bmf_member_ascx.CheckMembership(Object sender,
¤ EventArgs e) in \\TLBFS01\development\Projects\Tradecounter\Portal
¤ Development\TCCPortal
¤ Development\modules\bmf_validate_bmf_member.ascx:line 41

You need to use a UNC path to the file. Personally I'd recommend a DSN-less connection using Jet
OLEDB and the Excel ISAM driver rather than the Excel ODBC driver.

Also, IIS and ASP.NET implement a difference security mechanism so you may experience a credential
delegation issue if the file is on a system that is remote from the web server.

ASP.NET Delegation
http://msdn.microsoft.com/library/de...delegation.asp


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
Karl
Guest
Posts: n/a
 
      12th Jul 2005
I thought the whole purpose of DSN's is for exactly this kind of thing,
accessing data on a remote system and across platforms.

How do I use a unc path to the file if the file it hosted on an ISPs
webserver?

 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      12th Jul 2005
You would specify a relative path to the Server.MapPath() method and that
method would return the full physical path.

DSN-Less connections are defiantly the way to go.


"Karl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I thought the whole purpose of DSN's is for exactly this kind of thing,
> accessing data on a remote system and across platforms.
>
> How do I use a unc path to the file if the file it hosted on an ISPs
> webserver?
>



 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      12th Jul 2005
On 12 Jul 2005 05:52:55 -0700, "Karl" <(E-Mail Removed)> wrote:

¤ I thought the whole purpose of DSN's is for exactly this kind of thing,
¤ accessing data on a remote system and across platforms.
¤

DSNs were designed for ODBC based connections, typically for server based databases (which typically
take into consideration remote access) and not file based data stores, although you can use them for
that.

¤ How do I use a unc path to the file if the file it hosted on an ISPs
¤ webserver?

If the file is located on the web server then you can use Server.MapPath as Scott mentioned.
However, the authenticated user must still have sufficient permissions to access the resource. If
your web application is not implementing impersonation, the authenticated user would be ASPNET
(under Windows 2000) and NetworkService (under Windows 2003 Server).


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
After using Remote Desktop to connect to a remote PC, the remote PC'smonitor does not go back into standby mode NoelHo Windows XP General 0 6th Jan 2009 04:00 PM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Windows XP Work Remotely 2 15th Dec 2004 02:50 AM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Windows XP General 1 11th Dec 2004 09:09 PM
once try to connect to the remote computer,it'll restart but can't connect finally =?Utf-8?B?Z3JhbW15?= Windows XP Work Remotely 0 21st May 2004 04:41 AM
ODBC Call Failed with complete Connect string but not with ODBC only. =?Utf-8?B?QmV0YWNvbg==?= Microsoft Access Form Coding 1 19th Feb 2004 01:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:05 AM.