Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. OLE Databinding

OLE Databinding

Scheduled Pinned Locked Moved Visual Basic
databasecom
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Milancie
    wrote on last edited by
    #1

    :confused: The following works if only one row & one column is returned in a function Dim ssql As String ssql = "select full_name from EMPLOYEE WHERE full_name = '" & usertoLookup & "'" Dim myCommand As New OleDb.OleDbCommand(ssql, OleDbConnection1) OleDbConnection1.Open() EngActivitiesToFind = myCommand.ExecuteScalar() myCommand.Dispose() OleDbConnection1.Close() The following works if dataset / dataview returns multiple rows to bind to datagrid in a function Dim myCommand As New OleDb.OleDbCommand(strsql, myConnection) Dim MyAdapter As New OleDb.OleDbDataAdapter(myCommand) myConnection.Open() MyActivityDataSet.Clear() MyAdapter.Fill(MyActivityDataSet, "dcr_track") EngActivityDataView.Table.Clear() DataGrid_DCR.Refresh() EngActivityDataView = MyActivityDataSet.Tables("dcr_track").DefaultView DataGrid_DCR.DataSource = EngActivityDataView But how do you handle it in a single function if sometimes your retrieve returns multiple rows and other times a single row dependent on a query that is dynamic and dependent on user input Thanks Milancie

    P 1 Reply Last reply
    0
    • M Milancie

      :confused: The following works if only one row & one column is returned in a function Dim ssql As String ssql = "select full_name from EMPLOYEE WHERE full_name = '" & usertoLookup & "'" Dim myCommand As New OleDb.OleDbCommand(ssql, OleDbConnection1) OleDbConnection1.Open() EngActivitiesToFind = myCommand.ExecuteScalar() myCommand.Dispose() OleDbConnection1.Close() The following works if dataset / dataview returns multiple rows to bind to datagrid in a function Dim myCommand As New OleDb.OleDbCommand(strsql, myConnection) Dim MyAdapter As New OleDb.OleDbDataAdapter(myCommand) myConnection.Open() MyActivityDataSet.Clear() MyAdapter.Fill(MyActivityDataSet, "dcr_track") EngActivityDataView.Table.Clear() DataGrid_DCR.Refresh() EngActivityDataView = MyActivityDataSet.Tables("dcr_track").DefaultView DataGrid_DCR.DataSource = EngActivityDataView But how do you handle it in a single function if sometimes your retrieve returns multiple rows and other times a single row dependent on a query that is dynamic and dependent on user input Thanks Milancie

      P Offline
      P Offline
      pxw
      wrote on last edited by
      #2

      Use the "ExecuteReader" function to obtain a rataReader object. Then you can read the rows one at a time. Alternatively, you can instantiate a DataSet and "fill" it with your connection and then access the data in the dataset as you would any other database, or use it to fill your datagrid. There are actually lots of choices and I'm not sure which best fits your situation pxw

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups