ADO.NET: Pass the query string to the program

xiaoxiao2021-03-06  72

Page query.aspx can be queried in the database based on the passable ID parameters, such as http: //gqa-eric-lv/aspnet/mybbsquery/query.aspx? ID = 26 program can be used in this.request.QueryString [" ID "] Get the value of the query string ID, such as the following example: SqlConnection Coredb = new SqlConnection (); Coredb.connectionstring =" Workstation ID = / "gqa-eric-lv /"; packet size = 4096; integrated security = sspi; " " Data Source = / "GQA-Eric-LV /"; Persist 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 ()! = ""); string myselectquery = "SELECT ID, TITLE, Content from mybbs where id =" QueryId;

Sqlcommand mycommand = new sqlcommand (MySelectQuery, Coredb);

Coredb.open (); sqldatarader 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 ();}

转载请注明原文地址:https://www.9cbs.com/read-91674.html

New Post(0)