Connecting to an external database using a filedsn

SAD

Member
Joined
Aug 29, 2007
Messages
15
Programming Experience
Beginner
Hi

I am needing to connect to an external database using filedsn but I am not having much luck at the moment.

Initially I tried:

Dim conn = New Odbc.OdbcConnection
conn.ConnectionString = "FileDsn=Inserted my fieldsn here"

but it complained with:

type odbc.odbcconnection not defined

thought I just needed to Import something but couldn't get it to work so revised it to:

Dim conn = New Data.Odbc.OdbcConnection
conn.ConnectionString = "FileDsn=inserted my filedsn here"

and tried again but got the following error instead:

ERROR [HY000] General error: Invalid file dsn ''
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Odbc.OdbcException: ERROR [HY000] General error: Invalid file dsn ''

Source Error:


Line 34:
Line 35: ' open connection
Line 36: conn.Open()


I am unsure if it is my code or if I need to set something up on my home pc to allow me to access the external database which the filedsn is referring to? :confused:

Completely new to this so any pointers in the right direction would be great. Don't know if it helps/makes a difference but I am using vb.net on Windows Vista Home Premium....

Hope something can help

thanks
 
Hi

This is still driving me mad as I am sure I am just not understanding dsn files!

The dsn file which I need to access is on another pc, which i do not have a direct link to so could this be the problem?

When I have completed my website it will run on the same machine where the dsn file is stored so I assume my connectionstring would work then, but for development purposes should I copy the dsn file to my local machine, and paste it into:

c:\Program Files\Common Files\ODBC\Data Sources



Or would I need to create a temporary ODBC just to test my program?

Any hints/links to useful websites would be appreciated....
 
I understand now what I have to do - basically replicate the server I will put my program on when it is complete - obviously really!

suitably embarrassed :eek:
 
Back
Top