ASP Database Connection
HI
I have made a .asp guestbook that works with a .mdb database.
Everything works fine on my PC (IIS).
Now i uploaded the page, the DB and the connection but i cant get the connection to work i just keep getting diffrent errors over and over.
If i do this:
Code:
<%
// FileName="Connection_odbc_conn_dsn.htm"
// Type="ADO"
// DesigntimeType="ADO"
// HTTP="false"
// Catalog=""
// Schema=""
Set Conn =Server.CreateObject(ADODB.Connection);
strConnection="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/Twentyonedays/db/guestbook2000.mdb;Uid="Admin";Pwd="xxxx"";
oConn.Open(strConnection);
%>
I get an error in my connection file:
Microsoft JScript compilation error '800a03ec'
Expected ';'
/twentyonedays/Connections/Guestbook.asp, line 8
Set Conn =Server.CreateObject(ADODB.Connection);
If i do this:
Code:
<%
// FileName="Connection_odbc_conn_dsn.htm"
// Type="ADO"
// DesigntimeType="ADO"
// HTTP="false"
// Catalog=""
// Schema=""
strConnection="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/Twentyonedays/db/guestbook2000.mdb;Uid=Admin;Pwd=xxxxx";
%>
I get an error in my site (not the connection)
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/twentyonedays/Gaestebuch.asp, line 43
Line 43 sais:
Code:
rsGuestbook_cmd.ActiveConnection = MM_Guestbook_STRING;
I hope i could give enough information and someone can maybe help me.
Regards
Robin!
as i remember line
Set Conn =Server.CreateObject(ADODB.Connection);
shoiuuld be
Set Conn =Server.CreateObject("ADODB.Connection")
and it is no ; on the end of each line it is classic asp
Code:
<%
dim Conn
set Conn = Server.CreateObject("ADODB.Connection")
strConnection="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/Twentyonedays/db/guestbook2000.mdb;Uid=Admin;Pwd=mentos";
oConn.Open(strConnection)
%>
Gives me this error msg:
Microsoft JScript compilation error '800a03ec'
Expected ';'
/twentyonedays/Connections/Guestbook.asp, line 2
dim Conn
----^
you do not need to dim anything
If i remove the "dim"
Code:
<%
set Conn = Server.CreateObject("ADODB.Connection")
strConnection="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/Twentyonedays/db/guestbook2000.mdb;Uid=Admin;Pwd=xxxxxx";
oConn.Open(strConnection)
%>
I get this error and i dont understand whats wrong with the line:
Microsoft JScript compilation error '800a03ec'
Expected ';'
/twentyonedays/Connections/Guestbook.asp, line 2
set Conn = Server.CreateObject("ADODB.Connection")
----^
Your semicolon is outside the quotes, it should be inside.
Pwd=xxxxxx;"
Hi guys to give it a little update: I still cant get it too work so i decided to post my code maybe some1 can give me a hand: I would be so thankfull
The page that uses the Database looks like this
Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/gb.asp" -->
<%
var rsGB_cmd = Server.CreateObject ("ADODB.Command");
rsGB_cmd.ActiveConnection = MM_gb_STRING;
rsGB_cmd.CommandText = "SELECT * FROM Guestbook";
rsGB_cmd.Prepared = true;
var rsGB = rsGB_cmd.Execute();
var rsGB_numRows = 0;
%>
<%
var Repeat1__numRows = 10;
var Repeat1__index = 0;
rsGB_numRows += Repeat1__numRows;
%>
The connection looks like this
Code:
<%
// FileName="Connection_odbc_conn_dsn.htm"
// Type="ADO"
// DesigntimeType="ADO"
// HTTP="false"
// Catalog=""
// Schema=""
var MM_gb_STRING = "dsn=Guestbook;"
strConnection = "DRIVER=Microsoft Access Driver(*.mdb);DBQ=" & Server.MapPath("/twentyonedays/db/guestbook2000.mdb")
%>
And this is the error i get
Code:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/twentyonedays/Connection test.asp, line 5
I am using no password for testing purpose now.
This WILL work for a DSN-less connection
Code:
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"DATA SOURCE=" & server.mappath("twentyonedays/db/guestbook2000.mdb")
sql = "select * from Guestbook"
set rs=Conn.Execute(sql)
do until rs.eof
response.write rs(0) & "<br>"
rs.movenext
loop
rs.close
set rs=nothing
Thanks alot for your help!!!
But i get this error always when i use this line
Set Conn=Server.CreateObject("ADODB.Connection")
Code:
Microsoft JScript compilation error '800a03ec'
Expected ';'
/twentyonedays/db/Guestbook.asp, line 2
Set Conn=Server.CreateObject("ADODB.Connection")
----^
That's because your using Javascript instead of VBscript. You will need to re-write slightly to accommodate that.
Thank you soo much for your help!!! I have changed the code to VBSkript.
I have got the connection running but i still have a bug. Somehow before the page even starts i get this:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
http://users8.jabry.com/twentyonedays/Guestbooktest.asp Here is a link to the page. Thanks ALOT!
Last edited by Twentyonedays; 11-08-2011 at 12:52 PM .
The actual site:
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/Guestbook.asp" -->
<%
Dim rsGuestbook
Dim rsGuestbook_cmd
Dim rsGuestbook_numRows
Set rsGuestbook_cmd = Server.CreateObject ("ADODB.Command")
rsGuestbook_cmd.ActiveConnection = MM_Guestbook_STRING
rsGuestbook_cmd.CommandText = "SELECT * FROM Guestbook"
rsGuestbook_cmd.Prepared = true
Set rsGuestbook = rsGuestbook_cmd.Execute
rsGuestbook_numRows = 0
%>
The connection string:
Code:
<%
Dim MM_Guestbook_STRING
Set MM_Guestbook_STRING = Server.CreateObject("ADODB.Connection")
MM_Guestbook_STRING.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"DATA SOURCE=" & Server.MapPath("/twentyonedays/db/guestbook2000.mdb")
sql = "select * from Guestbook"
set rs=MM_Guestbook_STRING.Execute(sql)
do until rs.eof
response.write rs(0) & "<br>"
rs.movenext
loop
rs.close
set rs=nothing
%>
sure and you have i gues 25 records in your guestbook
that lopp creates that
Code:
do until rs.eof
response.write rs(0) & "<br>"
rs.movenext
loop
rs.close
THANK YOU ALL ALOT!!!!! You were so helpfull!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
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
Bookmarks