Results 1 to 4 of 4

Thread: Converting a reader (VB.NET)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    Pennsylvania
    Posts
    133

    Converting a reader (VB.NET)

    I populated a data reader and was wondering how to move it to a dataset, so I can make changes and write it back to the database.

    Maybe I should have put it in a dataset in the first place. Any help would be appreciated.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    maybe this..not 100% sure


    myDataReader.Fill(myDataSet, "Table name")
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    pvb
    Guest
    if you need to convert a datareader into a dataset then you need to rework your app. those were developed for two separate purposes(the DataReader for very high speed readonly data access and the other for very rich disconnected data access). if you need to update data either fill up a dataset right from the go(fyi, the DataAdapter has the .Fill method not the DataReader) or: query the db using the reader, take out the items you need to update(probably assign them to local variables or something), lose the DataReader(cuz it's readonly), do whatever you want to the local variables, then create a command object and manually build your update sql statement writing in the params using the local variables for the values.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    Pennsylvania
    Posts
    133

    Is this correct when utilizing a stored Proc

    Is this correct for using a stored procedure

    Public Sub PopulateMainTable(ByVal strConnect As String)

    Dim cn As OleDbConnection = New OleDbConnection(strConnect)
    Dim cmd As OleDbCommand = New OleDbCommand("spTapeCaliperEmp", cn)

    cmd.CommandType = CommandType.StoredProcedure
    cn.Open()

    Dim da As OleDbDataAdapter = New OleDbDataAdapter()
    da.SelectCommand = cmd

    Dim ds As DataSet = New DataSet()
    da.Fill(ds, "spTapeCaliperEmp")

    'WriteMainData(myReader, strConnect)
    cn.Close()
    end sub

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