ado| Program | String page query.aspx can query in the database based on the passed ID parameters, such as:
Http://gqa-eric-lv/aspnet/MyBBSQuery/query.aspx?id=26
This can be used in programs. request.querystring["id" gets the value of the query string ID, as in the following example:
SqlConnection coredb=new SqlConnection ();
coredb.connectionstring= "Workstation id=\" gqa-eric-lv\ ";p acket size=4096;integrated Security=sspi;"
"Data source=\" gqa-eric-lv\ ";p ersist security info=false;initial catalog=coredb";
int queryid=3;
String Idstr=textbox2.text.trim ();
Queryid=convert.toint32 (this. request.querystring["ID"]);
if (queryid<0| | TextBox2.Text.Trim ()!= "") return;
String myselectquery = "Select Id,title,content from Mybbs where id=" +queryid;
SqlCommand mycommand = new SqlCommand (myselectquery,coredb);
Coredb.open ();
SqlDataReader myreader = Mycommand.executereader ();
Try
{
while (Myreader.read ())
{
textbox1.text=myreader["title"]. ToString ();
textbox2.text=myreader["ID"]. ToString ();
textbox3.text=myreader["Content"]. ToString ();
}
}
Finally
{
Myreader.close ();
Coredb.close ();
}