how return Dataadapter and dataset from function in class file for multiple use
-
i 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.
-
i 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.
Don't cross post in multiple forums. Have a look at out parameters.