ianripping
02-25-2004, 12:59 PM
Can anyone tell me what is incorrec about his code?
My access file is called FeedBack.mdb, my table is called tblFeeds and my fields are called "name" and "comments"
<%
Dim Conn
Dim Rs
Dim sql
'Create an ADO connection and recordset object
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
'Set an active connection and select fields from the database
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("FeedBack.mdb")
sql= "SELECT name, comments FROM tblFeeds;"
'Set the lock and cursor type
Rs.CursorType = 2
Rs.LockType = 3
Rs.Open sql, Conn 'Open the recordset with sql query
set rs = server.createObject("ADODB.recordSet") '|Set the ADO recordSet object.
sql_query = "SELECT TOP 1 * FROM tblFeeds ORDER BY rec_id DESC"
rs.open(sql_query) '|Execute the SQL query.
'|Now we print the record out to the screen.
response.write("Name: " & rs("name") & vbCrLf)
response.write("Comments: " & rs("comments") & vbCrLf)
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
%>
My access file is called FeedBack.mdb, my table is called tblFeeds and my fields are called "name" and "comments"
<%
Dim Conn
Dim Rs
Dim sql
'Create an ADO connection and recordset object
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
'Set an active connection and select fields from the database
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("FeedBack.mdb")
sql= "SELECT name, comments FROM tblFeeds;"
'Set the lock and cursor type
Rs.CursorType = 2
Rs.LockType = 3
Rs.Open sql, Conn 'Open the recordset with sql query
set rs = server.createObject("ADODB.recordSet") '|Set the ADO recordSet object.
sql_query = "SELECT TOP 1 * FROM tblFeeds ORDER BY rec_id DESC"
rs.open(sql_query) '|Execute the SQL query.
'|Now we print the record out to the screen.
response.write("Name: " & rs("name") & vbCrLf)
response.write("Comments: " & rs("comments") & vbCrLf)
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
%>