Help Ado

Aoami

I am a FH squatter
Joined
Dec 22, 2003
Messages
11,223
Why this no work?

Code:
<div id="roster"> <!--roster div-->

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.ACE.OLEDB.12.0"
conn.Open "Roster.accdb"

rs.Open "SELECT Number, FirstName, LastName FROM Roster", conn
%>

<table border="1" width="100%">
  <tr>
  <%for each x in rs.Fields
    response.write("<th>" & x.name & "</th>")
  next%>
  </tr>
  <%do until rs.EOF%>
    <tr>
    <%for each x in rs.Fields%>
      <td><%Response.Write(x.value)%></td>
    <%next
    rs.MoveNext%>
    </tr>
  <%loop
  rs.close
  conn.close
  %>
</table>


</div> <!--end roster div-->

Access database called Roster.accdb, table inside the database called Roster, and this .ASP file, all in the same folder. I want the marked fields (Number, FirstName, LastName) to appear in a table in the roster div. I get an empty 1 column 1 row table.

?

Thanks.
 

Aoami

I am a FH squatter
Joined
Dec 22, 2003
Messages
11,223
Just a note. I'm doing this on a networked PC at the university. Will this make a difference? Would it net to be a ODBC connection as its on a network drive?

Would it work fine if I did it on my pc at home?
 

Raven

Fuck the Tories!
FH Subscriber
Joined
Dec 27, 2003
Messages
44,800
Have you tried turning it off and back on again?
 

Punishment

Resident Freddy
Joined
Jan 23, 2005
Messages
8,604
Computer-y-u-no-work.jpg
 

Tuthmes

FH is my second home
Joined
Jun 18, 2004
Messages
5,495
Just a note. I'm doing this on a networked PC at the university. Will this make a difference? Would it net to be a ODBC connection as its on a network drive?

Would it work fine if I did it on my pc at home?

Disco!

and shouldnt it look like:


<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Customers", conn
%>

?
 

Killswitch

FH is my second home
Joined
Jan 29, 2004
Messages
1,584
Why this no work?

Code:
<div id="roster"> <!--roster div-->

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.ACE.OLEDB.12.0"
conn.Open "Roster.accdb"

rs.Open "SELECT Number, FirstName, LastName FROM Roster", conn
%>

<table border="1" width="100%">
  <tr>
  <%for each x in rs.Fields
    response.write("<th>" & x.name & "</th>")
  next%>
  </tr>
  <%do until rs.EOF%>
    <tr>
    <%for each x in rs.Fields%>
      <td><%Response.Write(x.value)%></td>
    <%next
    rs.MoveNext%>
    </tr>
  <%loop
  rs.close
  conn.close
  %>
</table>


</div> <!--end roster div-->

Access database called Roster.accdb, table inside the database called Roster, and this .ASP file, all in the same folder. I want the marked fields (Number, FirstName, LastName) to appear in a table in the roster div. I get an empty 1 column 1 row table.

?

Thanks.

Okay...I'm no wizz with this stuff, but I have a couple of questions;

1) Should you be instantiating your objects before assigning them?
2) I've seen lots of examples using the following syntax for the Open command;

conn.Open ("Provider= Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("Roster.accdb"))

and not specifying the .Provider attribute.

Not sure if this is of any use to you at all. The example I'm quoting from is here;

https://support.discountasp.net/KB/a362/how-to-query-an-access-2007-database-with-asp-using.aspx

Good luck!!
 

Aoami

I am a FH squatter
Joined
Dec 22, 2003
Messages
11,223
Disco!

and shouldnt it look like:


<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Customers", conn
%>

?

jesus, no idea how i missed that, i was doing it from the same tutorial as well. Not working properly yet but a step closer definitely.

Cheers mate.
 

Aoami

I am a FH squatter
Joined
Dec 22, 2003
Messages
11,223
ok, im fucking ADODB off, it's too hard. Is JS the best way to make tables sortable if you're not using a database and just adding the fields in html?
 

Tuthmes

FH is my second home
Joined
Jun 18, 2004
Messages
5,495
AJAX and perhaps PHP?

And about what it displays now, it looks like you're missing 1 small detail, which fks up your page. Ill have a ponder once my brain starts working (ie. coffee time).
 

Users who are viewing this thread

Top Bottom