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. how to return dataadapter and data set from the same function

how to return dataadapter and data set from the same function

Scheduled Pinned Locked Moved Visual Basic
tutorialannouncement
3 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.
  • H Offline
    H Offline
    hemrk
    wrote on last edited by
    #1

    have created function in class file. Public Shared Function dsCntrctET() As DataSet Dim sqlCntrct As String = "Select * from CNTRCT_ET where CNTRCT_ID=" & CISCNO Dim cmdCISContract As New OracleCommand Dim daCISCntrct As New OracleDataAdapter Dim dsCISCntrct As New DataSet Dim cmdCISBuilder As New OracleCommandBuilder Try With cmdCISContract .Transaction = myTransCIS .CommandText = sqlCntrct .Connection = cnCIS End With daCISCntrct = New OracleDataAdapter(cmdCISContract) daCISCntrct.FillSchema(dsCISCntrct, SchemaType.Source) cmdCISBuilder = New OracleCommandBuilder(daCISCntrct) With daCISCntrct .TableMappings.Add("Table", "CNTRCT_ET") .Fill(dsCISCntrct) .SelectCommand = cmdCISContract .InsertCommand = cmdCISBuilder.GetInsertCommand .UpdateCommand = cmdCISBuilder.GetUpdateCommand .DeleteCommand = cmdCISBuilder.GetDeleteCommand End With Catch ex As Exception MessageBox.Show(ex.Message) End Try Return (dsCISCntrct) End Function it returns dataset that i can use for getting value from table. but while saving data, i have to use dataadapter for da.update(ds,"table") and ds.acceptchanges. this i have to use in multiple forms as this data comes from 3rd party so i dont want to write this in every form . so i thought how to return data adapter and dataset from the same function. as i wanted to use daCISCntrct and dsCISCntrct.

    C 1 Reply Last reply
    0
    • H hemrk

      have created function in class file. Public Shared Function dsCntrctET() As DataSet Dim sqlCntrct As String = "Select * from CNTRCT_ET where CNTRCT_ID=" & CISCNO Dim cmdCISContract As New OracleCommand Dim daCISCntrct As New OracleDataAdapter Dim dsCISCntrct As New DataSet Dim cmdCISBuilder As New OracleCommandBuilder Try With cmdCISContract .Transaction = myTransCIS .CommandText = sqlCntrct .Connection = cnCIS End With daCISCntrct = New OracleDataAdapter(cmdCISContract) daCISCntrct.FillSchema(dsCISCntrct, SchemaType.Source) cmdCISBuilder = New OracleCommandBuilder(daCISCntrct) With daCISCntrct .TableMappings.Add("Table", "CNTRCT_ET") .Fill(dsCISCntrct) .SelectCommand = cmdCISContract .InsertCommand = cmdCISBuilder.GetInsertCommand .UpdateCommand = cmdCISBuilder.GetUpdateCommand .DeleteCommand = cmdCISBuilder.GetDeleteCommand End With Catch ex As Exception MessageBox.Show(ex.Message) End Try Return (dsCISCntrct) End Function it returns dataset that i can use for getting value from table. but while saving data, i have to use dataadapter for da.update(ds,"table") and ds.acceptchanges. this i have to use in multiple forms as this data comes from 3rd party so i dont want to write this in every form . so i thought how to return data adapter and dataset from the same function. as i wanted to use daCISCntrct and dsCISCntrct.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Pass any other objects you want to return in as an out parameter.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      H 1 Reply Last reply
      0
      • C Christian Graus

        Pass any other objects you want to return in as an out parameter.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        H Offline
        H Offline
        hemrk
        wrote on last edited by
        #3

        i didnt really get you. can you please provide some small example.

        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