To tell you the truth...I can't really figure out where to edit the
information.....>< sorry! I get lost on what needs to be edited and
what doesn't...I'm new to asp.
An ADO Connection's Open method takes a single argument: a string
containing the information needed to connect to a data source. Your
ycode snip provides an example of this. The code assigns a string
containing connection information to a variable called sDSN:
sDSN = "DSN=" ...
It then calls the Open method of the Connection object, passing the
variable containing the connection string in the argument:
p_oConn.open sDSN
So, what you need to edit is the line of code that assigns the
connection string to the sDSN variable (an unfortunate choice of names
for the variable, but it doesn't really matter). Given that you did not
tell us the type or name of the database to which you are trying to
connect, I cannot be specific. In general:
This information in a connection string usually includes the name of an
OLE DB provider. If the provider name is not supplied, ADO assumes you
mean it to use the default OLE DB Provider for ODBC (called "MSDASQL").
So, given that you don't wish to use a DSN, you must supply the name of
the provider.
Provider=...;
The next bit of information the string needs to contain is the name of
the data source. For a server-based database such as SQL Server, this
will be the name or IP address (you may need to specify the network
library if using the IP address) of the server:
Data Source=ServerName;
or
Data Source=xxx.xx.xx.xxx
For a file-based database such as Jet (Access), this will be the path
and file name: it must be a file-system path, not a url, so if you wish
to use a virtual path to the file, you must use Server.MapPath to
generate the file-system path (these example assume Jet):
Data Source=p:\ath\to\databasefile.mdb;
or
Data Source=" & Server.MapPath("/db/databasefile.mdb") & ";"
For server-based databases, you can optionally supply the name of the
default database:
Initial Catalog=NameOfDatabase;
For server-based databases, you will need to supply the security info
needed for the connection. With SQL Server, the option exists to use
Windows or Integrated Authentication. This is rarely used in ASP, but it
is specified like this:
Integrated Security=SSPI;
More often, a user name and password will be supplied, like so:
UserID=SomeUser;Password=*******;
For Jet, unless a database is password protected or uses workgroup
security, no security information should be passed. See the FAQ article
or Carl Prothman's page (see the link below) for the syntax needed to
handle the other two cases.
Another optional piece of information I usually provide for server-based
databases is the name of the application. This aids in troubleshooting:
ApplicationName=Myapplication;
So, the idea is to put each piece of information together in a single
string, and pass that string to the Open method. This link might make it
clearer:
http://www.carlprothman.net/Default.aspx?tabid=81
Concentrate on the sections for OLE DB providers. Avoid ODBC unless
whatever database you are using has no OLE DB providers.
HTH,
Bob Barrows