|
-
Sep 19th, 2000, 01:02 PM
#1
Thread Starter
Member
i have a question for all the DB gurus out there. I am trying to connect to a DB on my ISP's server. I recently created a DSN for a program that works fine on my personal web server. To avoid my ISP creating a virtual ditrectory and so on.... someone suggested that I can create a connection directly and skip all the DSN stuff. I need help on the code to do so. Heres what I have:
---------------------------
Dim SqlJunk
Set dbGlobalWeb = Server.CreateObject("ADODB.Connection")
dbGlobalWeb.Open("Employees")
SqlJunk = "SELECT * FROM Employees"
--------------------------------
I appreciate all help, thanks!!!!!!!!!!!!!!!
-
Sep 19th, 2000, 01:38 PM
#2
Frenzied Member
You will need to know the DB server's name and supply the provider:
cn.ConnectionString = "Provider=SQLOLEDB;Server=Servername;Database=DatabaseName;UID=UserId;Pwd=Password;
Fill in the right-side values above with yours (assuming your using SQL Server you'll need to change the provider if not)
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Sep 19th, 2000, 02:08 PM
#3
Thread Starter
Member
ERRORS!
Now I have:
-----------------
Dim SqlJunk
Set con = CreateObject("ADODB.Connection")
con.ConnectionString="PROVIDER='MICROSOFT.JET.OLEDB.4.0';Server=servername;Database=employees.mdb;UI D=id;Pwd=password;"
con.Open
--------------------------------
I am getting:
Microsoft JET Database Engine error '80004005'
Could not find installable ISAM.
line 14
-------------------
I think it's when I open it???
-
Sep 19th, 2000, 03:05 PM
#4
Thread Starter
Member
ideas...
any ideas??? Or am I totally off on my code?????
Help anyone!!!!!!!!!!!
-
Sep 19th, 2000, 06:26 PM
#5
If you use Jet OLEDB provider, then you need to assign Data Source to a physical path to the database:
Code:
Dim cn
Set cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString="PROVIDER=MICROSOFT.JET.OLEDB.4.0;Data Source=C:\MyDatabase.mdb"
cn.Open
Notice C:\MyDatabase.mdb - it should be a physical path to the database on the server.
-
Sep 19th, 2000, 08:20 PM
#6
Frenzied Member
Probably a better idea would be to get the server path rather than hard code the path but Serge is right, for an access database you have to specify where it physically is.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Sep 19th, 2000, 10:07 PM
#7
Or better yet, create a DSN for an Access database on the server and then use DSN instead.
-
Sep 20th, 2000, 12:06 AM
#8
Frenzied Member
That would be ideal but it doesn't sound like he has direct access to the server. He is being hosted through an ISP. I doubt if they would be willing to set up a DSN on their server for him so a direct connection will be necessary.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Sep 20th, 2000, 09:21 AM
#9
He can create a file DSN that he can upload (since he probably has permissions to upload his files like ASP and HTML) to the server and use it almost the same as User/System DSN.
Code:
<%
Dim cn
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "FileDSN=MyDSN", UserName, Password
%>
-
Sep 20th, 2000, 10:45 AM
#10
Addicted Member
Just so you know
I just wana make sure you know this, a DSN is just a setting in the ODBC Registry, it allows you to use just a DSN name so that you dont have type out all that same information, but in both cases, you have the exact same information, just with a DSN , it's Pre-Saved in ODBC, and you can use it through out your program.
also if you are using a Access DB, your friend if viewing your ASP on a browser, will NEVER have direct access, but instead whatever you do with the Access will show out to the screen, you may use RDO (Remote Data Object) to truely have direct access through a browser, or you can setup a SQL Server, and have him log into a sql server using his own login tools, but using ADO, the user viewing the page never has direct access because it's a serverside process.
-
Sep 20th, 2000, 01:08 PM
#11
New Member
DSN-Less Connection is what you want
Here is an optimized vbscript of what you want to do, this should help you out...
Code:
Set DB = Server.CreateObject("ADODB.Connection")
DB.open "DBQ=" & SERVER.MapPath("your.mdb") & ";DRIVER={Microsoft Access Driver (*.mdb)};"
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set rs = Server.CreateObject("ADODB.Recordset")
cmDTemp.CommandText = "SELECT * FROM YourTable"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = DB
rs.Open cmdTemp, , 3, 3
This will allow you to not have to worry about where the database is located physically on the server, and better yet, if it is moved, your data won't crap out on you...this is also available for SQL7 databases as well...
Code:
strconn = "Driver={SQL Server};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID;PWD=Password;DATABASE=Database_Name
set conn = server.createobject("adodb.connection")
conn.open strconn
This should make you dangerous enough to continue on with your project...Good luck
My Humble Opinion is the only one that counts...just kidding.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|