主题:很简单的一个程序怎么一点反应都没有???
<script runat="server">
void submitBtn_Click(Object sender,EventArgs e){
OleDbConnection Conn=new OleDbConnection();
Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+Server.MapPath("db1.mdb");
Conn.Open();
string sql="select * from student";
if (mytext.Text!=""){
sql="select * from student where 姓名 like '%"+mytext.Text+"%'";
Message.Text=sql;
OleDbCommand Comm= new OleDbCommand(sql,Conn);
OleDbDataReader dr=Comm.ExecuteReader();
dg.DataSource=dr;
dg.DataBind();
Conn.Close();
}
}
</script>
请输入被查询的人名关键字<br>
<form name="myform" runat="server">
<asp:TextBox ID="mytext" runat="server"/><br>
<asp:Button ID="submit" OnClick="submitBtn_Click" runat="server" Text="查询" ></asp:Button><br>
<asp:Label ID="Message" runat="server"/><br>
<asp:DataGrid ID="dg" runat="server"/>
</form>
输入关键字后,点击查询,一点反应都没有?为什么?谢谢!!
void submitBtn_Click(Object sender,EventArgs e){
OleDbConnection Conn=new OleDbConnection();
Conn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+Server.MapPath("db1.mdb");
Conn.Open();
string sql="select * from student";
if (mytext.Text!=""){
sql="select * from student where 姓名 like '%"+mytext.Text+"%'";
Message.Text=sql;
OleDbCommand Comm= new OleDbCommand(sql,Conn);
OleDbDataReader dr=Comm.ExecuteReader();
dg.DataSource=dr;
dg.DataBind();
Conn.Close();
}
}
</script>
请输入被查询的人名关键字<br>
<form name="myform" runat="server">
<asp:TextBox ID="mytext" runat="server"/><br>
<asp:Button ID="submit" OnClick="submitBtn_Click" runat="server" Text="查询" ></asp:Button><br>
<asp:Label ID="Message" runat="server"/><br>
<asp:DataGrid ID="dg" runat="server"/>
</form>
输入关键字后,点击查询,一点反应都没有?为什么?谢谢!!