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
<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 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