I have an old ASP site (written a long time ago by a former employee) that connects to a 2003 ODBC database using DSN. The servers have been updated by our hosts to 2008, and we can no longer use ODBC so I have to make the connections DSN-Less.
Unfortunately I have very little knowledge of ASP, and database connections through ASP. I wonder if anybody can help me change the code to connect to the Access database without ODBC?
I think it connects using this code:
<%
' Get current name of region and intro text
Dim objRec, sql, introtext
sql="SELECT * FROM hometext WHERE home_id = 1"
set objRec=Server.CreateObject("ADODB.Recordset")
objRec.Open sql, "dsn=databasename"
introtext = Replace(objRec("home_introtext"), vbCrLf, "<br />")
' 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=databasename"
' Get all images to appear to page
Dim objRec3, sql3
sql3="SELECT * FROM homeimages ORDER BY homeimage_date DESC"
set objRec3=Server.CreateObject("ADODB.Recordset")
objRec3.Open sql3, "dsn=databasename"
' Get the next 5 events from the current date
Dim objRec4, sql4
sql4="SELECT TOP 5 event_date, event_name FROM events WHERE event_date >= " & niceDateAccess(Date()) & " ORDER BY event_date"
set objRec4=Server.CreateObject("ADODB.Recordset")
objRec4.Open sql4, "dsn=databasename"
%>
I’m not sure how it all connects, I’m not much of a scripter.
Any (dumbed down) help would be appreciated!
Thanks
EDIT: The database is sat in the ‘private’ folder in the root folder on the server.
Here is a sample code. Change your database name and tablefield name
You must give full access to your database by which user you are logged on.