web 2.0

VB.NET & System.Data.OracleClient - ExecuteReader()

VB.NET & System.Data.OracleClient - ExecuteReader() - How to learn Connector/NET ADO.NET component  System.Data.OracleClient namespace is the .NET Framework Data Provider for Oracle data source, Using the ExecuteReader method Sends the CommandText to the Connection and builds a DataReader (Oracle Server Database)

ShotDev Focus:
- VB.NET & System.Data.OracleClient - ExecuteReader()

Example

ExecuteReader.aspx

  1. <%@ Import Namespace="System.Data"%>  
  2. <%@ Import Namespace="System.Data.OracleClient"%>  
  3. <%@ Page Language="VB" %>  
  4. <script runat="server">  
  5. Dim objConn As System.Data.OracleClient.OracleConnection  
  6. Dim objCmd As System.Data.OracleClient.OracleCommand  
  7.   
  8. Sub Page_Load(sender As Object, e As EventArgs)  
  9. Dim strConnString As String  
  10. strConnString = "Data Source=TCDB;User Id=myuser;Password=mypassword;"  
  11. objConn = New System.Data.OracleClient.OracleConnection(strConnString)  
  12. objConn.Open()  
  13.   
  14. BindData()  
  15. End Sub  
  16.   
  17. Sub BindData()  
  18. Dim strSQL As String  
  19. strSQL = "SELECT * FROM customer"  
  20.   
  21. Dim dtReader As System.Data.OracleClient.OracleDataReader  
  22. objCmd = New System.Data.OracleClient.OracleCommand(strSQL, objConn)  
  23. dtReader = objCmd.ExecuteReader()  
  24.   
  25. '*** BindData to Repeater ***'  
  26. myRepeater.DataSource = dtReader  
  27. myRepeater.DataBind()  
  28.   
  29. dtReader.Close()  
  30. dtReader = Nothing  
  31.   
  32. End Sub  
  33.   
  34. Sub Page_UnLoad()  
  35. objConn.Close()  
  36. objConn = Nothing  
  37. End Sub  
  38.   
  39. </script>  
  40. <html>  
  41. <head>  
  42. <title>ShotDev.Com Tutorial</title>  
  43. </head>  
  44. <body>  
  45. <form id="form1" runat="server">  
  46. <asp:Repeater id="myRepeater" runat="server">  
  47. <HeaderTemplate>  
  48. <table border="1">  
  49. <tr>  
  50. <th>CustomerID</th>  
  51. <th>Name</th>  
  52. <th>Email</th>  
  53. <th>CountryCode</th>  
  54. <th>Budget</th>  
  55. <th>Used</th>  
  56. </tr>  
  57. </HeaderTemplate>  
  58. <ItemTemplate>  
  59. <tr>  
  60. <td align="center"><%#Container.DataItem("CustomerID") %></td>  
  61. <td><%#Container.DataItem("Name") %></td>  
  62. <td><%#Container.DataItem("Email") %></td>  
  63. <td align="center"><%#Container.DataItem("CountryCode") %></td>  
  64. <td align="right"><%#Container.DataItem("Budget") %></td>  
  65. <td align="right"><%#Container.DataItem("Used") %></td>  
  66. </tr>  
  67. </ItemTemplate>  
  68. </asp:Repeater>  
  69. </form>  
  70. </body>  
  71. </html>  

Screenshot

VB.NET & System.Data.OracleClient - ExecuteReader()
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.