Hi All,

Sorry if this isn't the appropriate place to put this question, but I'm new to the forums.

My issue relates to ASP and a DSN-less connection. I have a website, which was built quite a while ago using DSN connections to an Access database, which ran on a 2003 server. I have to replicate this site, but our servers (hosted through Fasthosts) are now 2008 servers, and don't support ODBC.

I have set up DSN-less connections, but I'm still not getting it right obviously as I keep getting Object required: 'object' on each page. I'm not really savvy with ASP, so if anybody can provide some answers that would be great!

The original code I had was this:

Get the 5 newest news items Dim objRec2, sql2, newstext sql2="SELECT TOP 5 news_date, news_text FROM news ORDER BY news_date DESC" set objRec2=Server.CreateObject("ADODB.Recordset") objRec2.Open sql2, "dsn=database"

Which I then changed to this:

Get the 5 newest news items set conob2 = Server.CreateObject("ADODB.Connection") conob2.Provider="Microsoft.Jet.OLEDB.4.0" conob2.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.MapPath("database.mdb") Set rsuni2 = Server.CreateObject("ADODB.Recordset") sql2="SELECT TOP 5 news_date, news_text FROM news ORDER BY news_date DESC" objRec2.Open sql, conob

I then get the error:

Microsoft VBScript runtime error '800a01a8'
Object required: 'objRec2'
index.asp, line 20

I'm running a 'WhileNot' statement to get the news_text and news_date like this:

<%While Not objRec2.EOF
                newstext = Replace(objRec2("news_text"), vbCrLf, "<br />")
                %>
                <p><span class="bold">Date: <%=objRec2("news_date")%></span><br />
                <%=newstext%></p>

Can anybody help with this please???

Many thanks!

I've also tried using the code:

set conob2 = Server.CreateObject("ADODB.Connection") conob2.Provider="Microsoft.Jet.OLEDB.4.0" conob2.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & server.MapPath("database.mdb") Set objRec2 = Server.CreateObject("ADODB.Recordset") sql2="SELECT TOP 5 news_date, news_text FROM news ORDER BY news_date DESC" objRec2.Open sql, conob2

Which results in:

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/index.asp, line 19

For the sake of clarity, let's say that your site is jonna.com and that your database.mdb is located at jonna.com/Databases/database.mdb.

try:

 'Get the 5 newest news items 
 Set conob2 = Server.CreateObject("ADODB.Connection") 
 conob2.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/Databases/database.mdb") & ";"
 Set objRec2 = Server.CreateObject("ADODB.Recordset") 

 Dim sql2
 sql2="SELECT TOP 5 news_date, news_text FROM news ORDER BY news_date DESC" 
 objRec2.Open sql, conob2, 1,3

NOTE: if the above doesn't work, try replacing:
Provider=Microsoft.Jet.OLEDB.4.0;

with:
Provider=Microsoft.ACE.OLEDB.12.0;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.