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. Problem using fill method on data adapter

Problem using fill method on data adapter

Scheduled Pinned Locked Moved Visual Basic
helpquestion
4 Posts 3 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.
  • S Offline
    S Offline
    ssbelfast
    wrote on last edited by
    #1

    okay, I'm a baby programmer, so don't laugh if this question is too obvious, but I've been stuck on this for hours now Very simple assignment - select data from an access data base using a data adapter and use the fill method to populate a data set I've looked at several examples that I've found on line and don't see what's wrong with my code. I always get a message on the adapter.fill line saying 'no value passed for one or more parameters' I see examples that dont just say adapter.fill(datasetname) and others that others that give a name for the name for the results within the data set, but I can't get either of these to work heres the latest attempt Thanks Protected Const CANDIDATESRESULTS As String = "Results" Protected connection As OleDbConnection = New OleDbConnection(connectionString) Public Sub OneCandidate(ByVal CandID As String) Dim candidateInfo As String = "SELECT * FROM CandidatesResults where CandidatesReulsts.CandidateID = '" & CandID & "'" Dim candAdapter As OleDbDataAdapter = New OleDbDataAdapter(candidateInfo, connection) candAdapter.SelectCommand = New OleDbCommand(candidateInfo, connection) candAdapter.Fill(candData, CANDIDATESRESULTS) DG.DataSource = candData DG.DataBind() Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=..\..\SampleDataBase.notadb" Dim candData As DataSet = New DataSet

    M 1 Reply Last reply
    0
    • S ssbelfast

      okay, I'm a baby programmer, so don't laugh if this question is too obvious, but I've been stuck on this for hours now Very simple assignment - select data from an access data base using a data adapter and use the fill method to populate a data set I've looked at several examples that I've found on line and don't see what's wrong with my code. I always get a message on the adapter.fill line saying 'no value passed for one or more parameters' I see examples that dont just say adapter.fill(datasetname) and others that others that give a name for the name for the results within the data set, but I can't get either of these to work heres the latest attempt Thanks Protected Const CANDIDATESRESULTS As String = "Results" Protected connection As OleDbConnection = New OleDbConnection(connectionString) Public Sub OneCandidate(ByVal CandID As String) Dim candidateInfo As String = "SELECT * FROM CandidatesResults where CandidatesReulsts.CandidateID = '" & CandID & "'" Dim candAdapter As OleDbDataAdapter = New OleDbDataAdapter(candidateInfo, connection) candAdapter.SelectCommand = New OleDbCommand(candidateInfo, connection) candAdapter.Fill(candData, CANDIDATESRESULTS) DG.DataSource = candData DG.DataBind() Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=..\..\SampleDataBase.notadb" Dim candData As DataSet = New DataSet

      M Offline
      M Offline
      MrSarek1701
      wrote on last edited by
      #2

      Your code is a little out of order... You are dim'ing your connection string and your dataset after you've already connected to the database and attempted to fill your dataset. Try this: Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=..\..\SampleDataBase.notadb" Dim candData As DataSet = New DataSet Dim con As OleDbConnection = New OleDbConnection(connectionString) Public Sub OneCandidate(ByVal CandID As String) Dim candidateInfo As String = "SELECT * FROM CandidatesResults where CandidatesResults.CandidateID = '" & CandID & "'" Dim candAdapter As OleDbDataAdapter = New OleDbDataAdapter(candidateInfo, con) candAdapter.Fill(candData, CANDIDATESRESULTS) DG.DataSource = candData DG.DataBind() -- modified at 15:09 Monday 17th July, 2006

      S 1 Reply Last reply
      0
      • M MrSarek1701

        Your code is a little out of order... You are dim'ing your connection string and your dataset after you've already connected to the database and attempted to fill your dataset. Try this: Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=..\..\SampleDataBase.notadb" Dim candData As DataSet = New DataSet Dim con As OleDbConnection = New OleDbConnection(connectionString) Public Sub OneCandidate(ByVal CandID As String) Dim candidateInfo As String = "SELECT * FROM CandidatesResults where CandidatesResults.CandidateID = '" & CandID & "'" Dim candAdapter As OleDbDataAdapter = New OleDbDataAdapter(candidateInfo, con) candAdapter.Fill(candData, CANDIDATESRESULTS) DG.DataSource = candData DG.DataBind() -- modified at 15:09 Monday 17th July, 2006

        S Offline
        S Offline
        ssbelfast
        wrote on last edited by
        #3

        thanks I can get this code to 'work' meaning not blowing up by dim the datagrid (Dim CandDG As DataGrid = New DataGrid) inside the class that contains this public sub the problem is the assignment calls for me to pass the data from the class to a form that calls the class. I haven't been able to get that to work

        K 1 Reply Last reply
        0
        • S ssbelfast

          thanks I can get this code to 'work' meaning not blowing up by dim the datagrid (Dim CandDG As DataGrid = New DataGrid) inside the class that contains this public sub the problem is the assignment calls for me to pass the data from the class to a form that calls the class. I haven't been able to get that to work

          K Offline
          K Offline
          Kschuler
          wrote on last edited by
          #4

          To pass the dataset from the class to the form you will need to modify the parameters of your method. Instead of just passing the ID string, you will also need to pass the dataset. But you will have to pass it by reference instead of by value. (passing by value will never change the original variable on the form side, by reference will) So it will look more like this: Public Sub MyMethodName(ByVal myID as String, ByRef myDataSet as DataSet) That should get you started.

          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