I’ve been trying for hours to try and get a simple example to work . This is basically a aflash file with two dynamic text boxes to read data from a database via an aspx page.
The database is MSSQL express 2005 called ThipiNoto and a News table which has a Title and Body Columns.Can some please help me in correcting my solution and make it work.
The flash code is
var myNews = new LoadVars();
myNews.Title =Title;
myNews.Body = Body;
myNews.onLoad = function() {
txtTitle.text = this.Title;
txtBody.text = this.Body;
}
myNews.sendAndLoad("Viewnews.aspx", myNews, 'POST');
}
The Asp.ent code(code behind file is)
public partial class Readnews : System.Web.UI.Page
{
public struct NUUS
{
public string Title;
public string Tody;
}
protected void Page_Load(object sender, EventArgs e)
{
Title = Request.Write("&Title");
Body = Request.Write("&Body");
SqlConnection link = new SqlConnection();
link.ConnectionString = (@"Data Source=ITCULATE-B98C32\SQLEXPRESS;Initial Catalog=TshipiNoto;Integrated Security=True");
const String sql = "SELECT FROM News(Title,Body)";
link.Open();
// Do work
//Create command and adapter
SqlCommand work = new SqlCommand(sql, link);
SqlDataAdapter da = new SqlDataAdapter();
//Assign command to adapter
da.SelectCommand = work;
//Create a dataset and fill it by using the adapter
DataSet ds = new DataSet();
da.Fill(ds);
NUUS[] nuus = new NUUS[ds.Tables[0].Rows.Count];
int count = 0;
foreach (DataRow dr in ds.Tables[0].Rows)
{
NUUS news = new NUUS();
news.Title = (string)dr["Title"];
news.Body = (string)dr["Body"];
nuus[count] = news;
count++;
}
return nuus;
//Close connection
link.Close();
}
}