By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,883 Members | 955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,883 IT Pros & Developers. It's quick & easy.

recored set

P: 3
How to use record set in dotnet2005
Apr 2 '07 #1
Share this Question
Share on Google+
1 Reply


P: 64
How to use record set in dotnet2005

The first step to add a reference to the ADO library. You can add reference to the ADO library by using Project->Add Reference menu item and then select COM tab seelct Microsoft ActiveX data Objects 2.7 Library.


After adding this reference, you'll see the ADODB namespace is added to your project

Projects->Reference->ADODB

Import namespace

Expand|Select|Wrap|Line Numbers
  1. Imports System.Data
  2. Imports System.Data.OleDb
  3. Imports ADODB
  4.  
  5.  
  6. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7. ' Create a connection string
  8. Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\Northwind.mdb"
  9. Dim sql As String = "SELECT CustomerId, CompanyName, ContactName From Customers"
  10.  
  11. Dim rs As _Recordset = conn.Execute(sql)
  12. ' Create dataset and data adpater objects
  13. Dim ds As DataSet = New DataSet("Recordset")
  14. Dim da As OleDbDataAdapter = New OleDbDataAdapter
  15. ' Call data adapter's Fill method to fill data from ADO
  16. ' Recordset to the dataset
  17. da.Fill(ds, rs, "Customers")
  18. ' Now use dataset
  19. DataGrid1.DataSource = ds.DefaultViewManager
  20. End Sub
  21.  
  22.  
  23.  

hope it work
Apr 2 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.