Declaring the SqlConnection and SqlCommand objects in a webform without CodeBehind
I am trying to query data from a MS SQL server with a C# web form without “CodeBehind”. I want to write the information to a table in the web form’s body.
I am having trouble declaring the SqlConnection and SqlCommand objects that connect to the server.
How do you use “using System;”, “using System.Data;”, “using System.Data.SqlClient” inside of script element of as .aspx file?
I know how to do it with JavaScript and ADO. (code below)
<html><head><table>
<%@ language="javascript" %>
<%
var sqlstr = " ";
var conn_str = " ";
var AdOpenForwardOnly = 0;
var adLockReadOnly = 1;
var rs = new ActiveXObject("ADODB.Recordset");
var conn = new ActiveXObject("ADODB.Connection");
Bookmarks