Results 1 to 4 of 4

Thread: [RESOLVED] [2005] ADO.NET DataSet DataAdapter

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    71

    [RESOLVED] [2005] ADO.NET DataSet DataAdapter

    I am attempting to populate two combo box in a form as the form loads using two subs

    PopulateActivity()
    Public Sub PopulateSites()

    it seems to work but when I look in the database after I enter the values
    I get Site
    System.Data.DataRowView

    Question: am I suppose to create a new DataSet and DataApapter for each combo box that I am trying to populate, since they
    get there info from different tables?


    file attached




    Code:
    Module Module1
        'created the variable conn that represents a new instance of 
        'OleDb.Connection Object
        Dim conn As New OleDb.OleDbConnection
        'created the variable DataSet that represents a new instance of the object DataSet
        Dim DataSet As New DataSet
        Dim SiteDS As New DataSet
    
        'create the variable DataAdapter as an instance of OleDB.OleDbDataApapter
        Dim DataAdapter As OleDb.OleDbDataAdapter
    
        Public CHCBTimeSheet As New TimeSheet
    
        Dim sql As String
        Dim MaxNumRows As Integer
    
    
       
    
    
        Public Sub PopulateActivity()
    
            conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" _
            & Application.StartupPath & "\TSDB.mdb"
    
            conn.Open()
    
            Dim sql2 As String
    
            sql2 = "SELECT Activity FROM tblActivity"
    
            DataAdapter = New OleDb.OleDbDataAdapter(sql2, conn)
    
    
            DataAdapter.Fill(DataSet, "Activity")
    
            EnterHours.cboActivity.DisplayMember = "Activity"
            'EnterHours.cboActivity.Valuemember = "Column Name of ID (if any)"
            EnterHours.cboActivity.DataSource = DataSet.Tables("Activity")
    
            conn.Close()
    
        End Sub
    
    
        Public Sub PopulateSites()
    
            conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" _
            & Application.StartupPath & "\TSDB.mdb"
    
            conn.Open()
    
            Dim sql3 As String
    
            sql3 = "SELECT site FROM tblSites"
    
            DataAdapter = New OleDb.OleDbDataAdapter(sql3, conn)
    
    
            DataAdapter.Fill(DataSet, "Sites")
    
            EnterHours.cboSite.DisplayMember = "Site"
            'EnterHours.cboSite.Valuemember = "Column Name of ID (if any)"
            EnterHours.cboSite.DataSource = DataSet.Tables("Sites")
    
            conn.Close()
    
        End Sub
    
    End Module
    Attached Files Attached Files
    Last edited by cedtech23; Nov 30th, 2006 at 05:02 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width