http://www.cnblogs.com/mephisto/archive/2013/01/25/2876213.html

解决方案 »

  1.   

    首先在数据库里建立表,有路径字段
    入库:          SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=table;Integrated Security=True");
                con.Open();
                SqlCommand cmd = new SqlCommand(string.Format("select Count(*) form table where 路径= '{0}'", textBox.Text), con);
                if ((int)cmd.ExecuteScalar() > 0)
                {
                    MessageBox.Show("数据已经存在", "提示");
                }
                else
                {
                    string sql = "insert into table(路径) values('" + textBox.Text + "')";
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("成功添加");
                }读取:tring queryString = select 路径 from table"; 
      using (SqlConnection connection = new SqlConnection( connectionString)) 
      { 
      SqlCommand command = new SqlCommand( queryString, connection);
    connection.Open(); 
      SqlDataReader reader = command.ExecuteReader(); 
      try 
      { 
      while (reader.Read()) 
      { 
         
       textbox1.Text=reader[0].ToString();  } 
      } 
      finally 
      { 
      
      } 
      } 
      }
      

  2.   

                WindowsMediaPlayer player = new WindowsMediaPlayer();
                player.URL = reader[0].ToString();