All pastes #995263 Raw Edit

Mine

public text v1 · immutable
#995263 ·published 2008-04-23 23:57 UTC
rendered paste body
protected void Page_Load(object sender, EventArgs e)
    {
        this.torrentResults = new SearchQuery();
        this.searchQuery = Request.QueryString["query"];

        if (searchQuery != null)
        {
            XmlSerializer resultSerializer = new XmlSerializer(typeof(SearchQuery));

            String mySelectQuery = "call search(\"" + this.searchQuery + "\")";
            MySqlConnection myConnection = new MySqlConnection(myConnString);
            MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection);
            myConnection.Open();
            MySqlDataReader searchResultReader = myCommand.ExecuteReader();

            try
            {
                while (searchResultReader.Read())
                {
                    String torrentID = searchResultReader.GetString(0);
                    String fileID = searchResultReader.GetString(1);

                    Debug.WriteLine(torrentID + " file: " + fileID);

                    this.torrentResults.AddResult(this.PopulateTorrent(Int32.Parse(torrentID), fileID));
                }
            }
            finally
            {
                searchResultReader.Close();
                myConnection.Close();
            }

            resultSerializer.Serialize(new FileStream("test.xml", FileMode.Create), this.torrentResults);

            if (XMLWriteToBuffer("test.xml"))
            {
                return;
            }
        }
        else
        {
            SearchQueryNotFound(this.searchQuery);
            return;
        }
    }