问题描述
<objectclassid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"height="64"align="top"id="MediaPlayer"style="width:623px"><paramname="URL"value="<%=url%>"/><paramname="Rate"value="1"/><paramname="Balance"value="0"/><paramname="CurrentPosition"value="0"/><paramname="DefaultFrame"value=""/><paramname="PlayCount"value="100"/><paramname="AutoStart"value="-1"/><paramname="CurrentMarker"value="0"/><paramname="InvokeURLs"value="-1"/><paramname="baseURL"value=""/><paramname="Volume"value="100"/><paramname="Mute"value="0"/><paramname="unMode"value="full"/><paramname="stretchToFit"value="0"/><paramname="WindowlessVideo"value="0"/><paramname="Enabled"value="-1"/><paramname="EnableContextMenu"value="-1"/><paramname="fullscreen"value="0"/><paramname="SAMIStyle"value=""/><paramname="SAMILang"value=""/><paramname="SAMIFileName"value=""/><paramname="CaptioningID"value=""/><paramname="Enableerrordialogs"value="0"/></object><br/><tablestyle="width:621px;height:356px;border-right:graythinsolid;border-top:graythinsolid;border-left:graythinsolid;border-bottom:graythinsolid;"><tr><tdalign="left"style="width:600px;height:2px;background-color:#ccccff;border-bottom:graythinsolid;">歌曲名:<asp:LabelID="lbl_musicname"runat="server"Width="200px"BorderStyle="None"ForeColor="Black"></asp:Label>歌手:<asp:LabelID="lbl_musician"runat="server"Width="113px"BorderStyle="None"ForeColor="Black"></asp:Label></td></tr><tr><tdstyle="width:600px"><asp:TextBoxID="tx_geci"TextMode="MultiLine"runat="server"Height="390px"Width="610px"></asp:TextBox></td></tr></table></asp:Content>usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Data.SqlClient;publicpartialclassplay:System.Web.UI.Page{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){//读取数据库连接字符串stringsettings=Convert.ToString(ConfigurationManager.ConnectionStrings["SqlServices"]);//创建数据库连接对象SqlConnectionmyconn=newSqlConnection();myconn.ConnectionString="IntegratedSecurity=SSPI;PersistSecurityInfo=true;InitialCatalog=gyl_DB;DataSource=gyl\SQLEXPRESS";myconn.Open();intid=Convert.ToInt32(Request.QueryString["id"]);stringstrsql="select*frommusicwheremusic_id="+id+"";SqlCommandmycmd=newSqlCommand(strsql,myconn);//SqlDataReader读取数据到记录集后,会自动关闭数据库的连接SqlDataReaderresult=mycmd.ExecuteReader();if(result.Read()){lbl_musicname.Text=result["music_name"].ToString();lbl_musician.Text=result["musician"].ToString();tx_geci.Text=result["geci"].ToString();stringurl=result["music_Url"].ToString();}}}}
解决方案
解决方案二:
定义全局变量在Page_load上面写publicstringUrl;
解决方案三:
缺少Url的定义
解决方案四:
把publicstringurl="";定义到page_load上面然后再page_load事件里对url赋值url=result["music_Url"].ToString();