I have ASp.net code stored in a SQL Server database. This code makes up templates. When I read the Code out with a DataReader but it is taken 'literal'. I am looking for a function like the eval() in PHP or someway of emulating this in ASP.Net using C#. Here
is my code:
This is the results of 'View Source' in the browser: This the exact string read from the database. It should process the variable and display the result. Can anyone help. Thsnks so much!
jbezanson
Member
735 Points
173 Posts
Stored ASP.Net code in Database - Reading with Datareader
Nov 19, 2004 05:54 PM|LINK
//Response.Write("Welcome to Page" + Request.QueryString["page"] + "! "); //Execute Sql Statement /////////////////////////////////////// string Sql = "SELECT * FROM Page_Content WHERE Page_ID = " + Request.QueryString["page"] + " AND Site_ID = '" + Session["Site_ID"].ToString() + "'"; SqlCommand mySqlCommand = new SqlCommand(Sql, mySqlConnection); SqlDataReader myDataReader = null; myDataReader = mySqlCommand.ExecuteReader(); //Variables to Fill ///////////////////////////////////// string sSite_Title = ""; string sHead_ID = ""; string sBody_ID = ""; string sFoot_ID = ""; string sPage_HTML = ""; string sType = ""; string sRelated_To = ""; //Filling Variables ///////////////////////////////////// sSite_Title = Session["Site_Title"].ToString(); //Response.Write(sSite_Title); while (myDataReader.Read()){ sHead_ID = myDataReader[2].ToString(); sBody_ID = myDataReader[3].ToString(); sFoot_ID = myDataReader[4].ToString(); sPage_HTML = myDataReader[5].ToString(); sType = myDataReader[6].ToString(); sRelated_To = myDataReader[7].ToString(); } //Response.Write(sHead_ID + " " + sBody_ID + " " + sFoot_ID + " " + sPage_HTML + " " + sType + " " + sRelated_To); %>This is the results of 'View Source' in the browser: This the exact string read from the database. It should process the variable and display the result. Can anyone help. Thsnks so much!Web Development Blog