﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace mp3web
{
    public partial class index : System.Web.UI.Page
    {
        protected void but_Click(object sender, EventArgs e)
        {
            if (txt.Text == "") { }
            else
            {
                String ser = txt.Text;
               
                String sql = "select * from mp3Info where name like '%" + ser + "%'";
                SqlDataAdapter da = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["connstring"].ToString());
                DataSet ds = new DataSet();
                da.Fill(ds);
                String ss = "";
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ss += "<h2>id: " + ds.Tables[0].Rows[i][0] +
                        " &nbsp&nbsp歌名: " + ds.Tables[0].Rows[i][1] +
                        " &nbsp&nbspurl: <a href=\"" + ds.Tables[0].Rows[i][2] +
                        "\" target=\"_blank\">" + ds.Tables[0].Rows[i][2] +
                        "</a></h2><br>";
                }
                Session["result"] = ss;
                Response.Write("<meta http-equiv='refresh' content='0;URL=result.aspx'>");

            }
        }
    }
}