ADO.NET: Pass the query string to the program

xiaoxiao2021-03-06  38

Source: Unknown Author: Unknown Recommended rating: Visits: 7

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 (); SqlDataReader myReader = myCommand.ExecuteReader (); try {while (myReader.Read ()) {TextBox1.Text = myReader [ "title"]. TEXTBOX2.TEXT = MyReader ["ID"]. TOSTRING (); TextBox3.text = myReader ["content"]. Tostring ();}} finally {myReader.close (); Coredb.close (); }

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

New Post(0)