Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When I try to execute this simple p

Status
Not open for further replies.

awesomebeats

Technical User
Nov 29, 2001
25
US
When I try to execute this simple piece of code in asp I get an access error. I know no other user is using the db so why can't asp access the db. I tried it without the username and password and it still didn't work.

<%
set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.open &quot;spelling&quot;,&quot;Admin&quot;,&quot;&quot;
strSQLQuery = &quot;create table employee (words varchar(50));&quot;
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open strSQLQuery, conn, 3, 3
%>

The error I get is:
Jet database engine cannot open the file '(unknown)'.
I don't know what it says the db is unkown I configured it in Microsoft ODBC thingy as a system db. Well I'm new to asp infact this is my first app, I usually use Coldfusion. I'd really appreciate a little help here. Oh yeah do I need to instal SQL server seperalty or does win2k and IIS have a little one built in? Thanx a lot.

Awesomebeats
 
Hi ...
If I think in a right way, spelling is the name of the DSN which you have created in the ODBC.
If so, you have to give a connection string to your Database to open it.
so you can do this :
cnnStr = &quot;DRIVER=Microsoft Access Driver (*.mdb);FIL=MS;Access;DefaultDir=C:\Inetpub\ but you have to give the path of your own DB and also you can use Server.MapPath to give the path.
and then you do this :

conn.open cnnStr,&quot;Admin&quot;,&quot;&quot;

TNX.
E.T.
 
As for your second question, SQL Server is a seperate installation.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Ok wait, so I can't do any sql or basically any db stuff without installing SQl server? And why can't I just use the DNS name, I'll try with this file path thingy, thanx? Gosh no wonder I've never done asp, so confusing. Lol, thanx for the help.

awesomebeats
 
Every database uses SQL the language. Microsoft SQL Server is just another database, not the actual language.
SQL as a language is merely standardized wording that all databases understand. Also, you can reference your database by either path or DSN. You will need to specify the DSN, username, and password in your connection string as you are above.
If you will print out your exact error I or someone else should be able to help you further.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Hi ...
well you can use youe ODBC but it's not recomended.
becouse you may want to move your code on some other machine which does not have the DSN created on it or even maybe you want to install your application on some machine
which doesn't have ODBC ...
so there is an other connection string that is better to use and that is Microsoft Jet OLEDB :
conn.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; & _
&quot;Data Source=c:\somepath\myDb.mdb;&quot; & _
&quot;User Id=admin;&quot; & _
&quot;Password=&quot;
this connection string is better ...

TNX.
E.T.
 
wow thanx a lot guys that really worked i used that last piece of code suggested and it ran fine. i had to give some permissions to the db for the internet user account and give it write persmisssions but it worked. thanx a lot guys!

awesomebeats
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top