OracleDataReader的两个用法

 
1. 在datagrid里创建4个BoundColumn和一个LinkButton。
 <asp:DataGrid id="DataGrid1" style="Z-INDEX: 110; LEFT: 16px; POSITION: absolute; TOP: 168px"
  Visible="True" runat="server" AutoGenerateColumns="False">
  <Columns>
   <asp:BoundColumn DataField="ID" HeaderText="ID"></asp:BoundColumn>
   <asp:BoundColumn DataField="NUM1" HeaderText="NUM1"></asp:BoundColumn>
   <asp:BoundColumn DataField="NUM2" HeaderText="NUM2"></asp:BoundColumn>
   <asp:BoundColumn DataField="NUM3" HeaderText="NUM3"></asp:BoundColumn>
   <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" HeaderText="Edit!" CancelText="Cancel"
    EditText="Edit"></asp:EditCommandColumn>
  </Columns>
 </asp:DataGrid> 
2. datagrid通过 OracleDataReader获得数据 
         Dim Orclcnn As OracleConnection
        Dim OrclComm As OracleCommand
        Dim OraclReader As OracleDataReader
        Try
            Orclcnn = New OracleConnection
            OrclComm = New OracleCommand
 
            Orclcnn.ConnectionString = "Data Source=edc81;User Id=test;Password=test"
            Orclcnn.Open()
            OrclComm.CommandText = "select * from test1 where id = 1"
            OrclComm.CommandType = System.Data.CommandType.Text
            OrclComm.Connection = Orclcnn
            OraclReader = OrclComm.ExecuteReader
            DataGrid2.DataSource = OraclReader
            DataGrid2.DataBind()
 
        Catch ex As Exception
            Throw ex
 
        Finally
            OraclReader.Close()
            Orclcnn.Close()
        End Try
3. 获取 OracleDataReader里特定列
        Dim Orclcnn As OracleConnection
        Dim OrclComm As OracleCommand
        Dim OraclReader As OracleDataReader
        Try
            Orclcnn = New OracleConnection
            OrclComm = New OracleCommand
 
            Orclcnn.ConnectionString = "Data Source=edc81;User Id=test;Password=test"
            Orclcnn.Open()
            OrclComm.CommandText = "select * from test1 where id = 1"
            OrclComm.CommandType = System.Data.CommandType.Text
            OrclComm.Connection = Orclcnn
            OraclReader = OrclComm.ExecuteReader
            OraclReader.Read()
            If OraclReader.HasRows = False Then
                Exit Try
            End If
            Label1.Text = CStr(OraclReader.Item(0)) + "aaaa" + _
CStr (OraclReader.Item(1)) + _
"bbbbb" + CStr(OraclReader.Item(2)) + "cccc" + _
CStr (OraclReader.Item(3))
        Catch ex As Exception
            Throw ex
        Finally
            OraclReader.Close()
            Orclcnn.Close()
        End Try
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值