⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listing1402.aspx

📁 asp入门到精通的源代码
💻 ASPX
字号:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
   'declare connection
   dim Conn as new OleDbConnection("Provider=" & _
            "Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=H:\ASPNET\data\banking.mdb")
   
   sub GetData(obj as Object, e as EventArgs) 
      dim objCmd as OleDbCommand = new OleDbCommand _
         ("select * from tblUsers where UserID = @ID", Conn)
      dim objReader as OleDbDataReader
      
      dim objParam as OleDbParameter
      objParam = objCmd.Parameters.Add("@ID", OleDbType.Integer)
      objParam.Direction = ParameterDirection.Input
      objParam.Value = tbID.Text
           
      try
         objCmd.Connection.Open()
         objReader = objCmd.ExecuteReader
      catch ex as OleDbException
         Label1.Text = "Error retrieving from the database."
      end try
       
      DataGrid1.DataSource = objReader
      DataGrid1.DataBind()
       
      objReader.Close
      objCmd.Connection.Close()
   end sub
</script>

<html><body>
   <form runat="server">
      <asp:Label id="Label1" runat="server"
         maintainstate=false /><br>
      Enter an ID: <asp:TextBox id="tbID" runat="server"
         AutoPostBack=True
         OnTextChanged=GetData /><p>
      <asp:DataGrid id="DataGrid1" runat="server" 
         BorderColor="black" 
         GridLines="Vertical" 
         cellpadding="4" 
         cellspacing="0" 
         width="100%"
         Font-Name="Arial" 
         Font-Size="8pt" 
         HeaderStyle-BackColor="#cccc99"
         ItemStyle-BackColor="#ffffff"
         AlternatingItemStyle-Backcolor="#cccccc"
         AutoGenerateColumns="true" />
   </form>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -