Connection.openrs — execute an SQL select statement and return the recordset


Recordset Connection.openrs ( sql);  
string   sql;


Use this method to execute an SQL select statement and have the results returned in a Recordset object. If the SQL query is an update instead of a select then the result is undefined. If the query is invalid then null is returned and you can use the error() function to get the error message.

The SQL query should be on a single line without comments or leading or trailing whitespace.

Example 63. Connection.openrs Example

Recordset rs = conn.openrs("SELECT * FROM mytable");
if(rs == null)
    %><p>Error: <%=htmlencode(error())%></p><%
    // Do something with the results

See Also

Data sources and database access in RSP is explained in the section called “Accessing Databases”