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