-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: sreenivas_mr
Message 1 in Discussion
Hi All, I have a remote component(dll installed in GAC of remote machine) which has
the following piece of code Public Function UpdateFromDataset(ByRef oDS As
ServerModeDataset) As Boolean Dim objCommand As SqlCommand
Dim strConn As String
Dim objDA As SqlDataAdapter
Dim objAppConfig As AppConfig
Dim objAppLog As AppLog
Dim oTraceSwitch As TraceSwitch
Dim oTempDS As ServerModeDataset Try
objAppConfig = New AppConfig()
objAppLog = New AppLog()
oTraceSwitch = New TraceSwitch("TraceLevelSwitch",
"OPSCRemoteServerTraceLevelSwitch")
oTraceSwitch.Level = objAppConfig.GetTraceLevelSwitch()
Catch ExcepExecSPOutputValuesTraceLevelSwitch As Exception
If Not IsNothing(oTraceSwitch) Then
oTraceSwitch = Nothing
End If
If Not IsNothing(objAppConfig) Then
objAppConfig = Nothing
End If
If Not IsNothing(objAppLog) Then
objAppLog = Nothing
End If
Throw New Exception("From DBOperations ExecSPOutputValues : " & vbCrLf
& ExcepExecSPOutputValuesTraceLevelSwitch.ToString)
End Try 'To get the connection string from the config file.
Try
strConn = objAppConfig.GetConnectionString
If oTraceSwitch.TraceInfo Then
objAppLog.Write("<Class : DBOperations> : <Method :
ExecSPOutputValues> : Getting the Connection String. - Success.")
End If
Catch objExcep As Exception
If oTraceSwitch.TraceError Then
objAppLog.Write("<Class : DBOperations> : <Method :
ExecSPOutputValues> : Getting the Connection String. - Fail." & objExcep.ToString)
Throw New Exception("From DBOperations ExecSPOutputValues : " &
vbCrLf & objExcep.ToString)
End If
End Try 'Open the connection object
Try
objCommand = New SqlCommand("select * from server_mode", New
SqlConnection(strConn))
objCommand.CommandType = CommandType.Text
objDA = New SqlClient.SqlDataAdapter(objCommand)
oTempDS = New ServerModeDataset()
If oTraceSwitch.TraceInfo Then
objAppLog.Write("<Class : DBOperations> : <Method : ExecSP> :
Initialize the SqlDataAdapter object. - Success.")
End If ' A SqlCommandBuilder automatically generates
the SQL commands needed
' to update the database later.
Dim scb As New SqlCommandBuilder(objDA)
oTempDS.EnforceConstraints = False
objDA.Fill(oTempDS, "server_mode")
oTempDS = oDS
objDA.Update(oTempDS, "server_mode") Dim od As New
tes() objDA.Fill(od, "test")
od.test.Rows(1).Item("name") = "saibaba"
od.AcceptChanges()
objDA.Update(od, "test") If oTraceSwitch.TraceInfo Then
objAppLog.Write("<Class : DBOperations> : <Method :
ExecSPOutputValues> : Open the connection object. - Success.")
End If
Catch objExcepOpen As Exception
If oTraceSwitch.TraceError Then
objAppLog.Write("<Class : DBOperations> : <Method :
ExecSPOutputValues> : Open the connection object. - Fail." & objExcepOpen.ToString)
Throw New Exception("From DBOperations ExecSPOutputValues : " &
vbCrLf & objExcepOpen.ToString)
End If Finally
If Not IsNothing(objCommand) Then
Try
objCommand.Connection.Close()
If oTraceSwitch.TraceInfo Then
objAppLog.Write("<Class : DBOperations> : <Method :
ExecSPOutputValues> : Closing the SQLCommand object. - Success.")
End If
Catch ExcepCloseCommand As Exception
If oTraceSwitch.TraceError Then
objAppLog.Write("<Class : DBOperations> : <Method :
ExecSPOutputValues> : Closing the SQLCommand object. - Fail." &
ExcepCloseCommand.ToString)
End If
Throw New Exception("From DBOperations ExecSPOutputValues : "
& vbCrLf & ExcepCloseCommand.ToString)
End Try
End If
End Try Try
If Not IsNothing(oTraceSwitch) Then
oTraceSwitch = Nothing
End If
Catch ExcepDisposeTraceSwitch As Exception
Throw New Exception("From DBOperations ExecSPOutputValues : " & vbCrLf
& ExcepDisposeTraceSwitch.ToString)
End Try Try
If Not IsNothing(objAppConfig) Then
objAppConfig = Nothing
End If
Catch ExcepDisposeAppConfig As Exception
Throw New Exception("From DBOperations ExecSPOutputValues : " & vbCrLf
& ExcepDisposeAppConfig.ToString)
End Try Try
If Not IsNothing(objAppLog) Then
objAppLog = Nothing
End If
Catch ExcepDisposeAppLog As Exception
Throw New Exception("From DBOperations ExecSPOutputValues : " & vbCrLf
& ExcepDisposeAppLog.ToString)
End Try End Function
changes are updated in the DataSet but the database is not getting updated. There is
no exception being thrown. A similar piece of code in another application which is
an exe application is working fine. The code is as below. ' This subroutine
takes a passed DataSet and updates the Northwind
' database, with the changes.
Public Sub UpdateDataSet(ByVal inDS As DataSet) ' If the DataSet that was
passed in is Nothing, exit this subrouting.
If inDS Is Nothing Then
Exit Sub
End If Try
' First verify that the data adapters have been created, and call
' the CreateDataSet to build them if necessary.
If (Me.sdaProducts Is Nothing Or Me.sdaSuppliers Is Nothing) Then
CreateDataSet()
End If ' Try to Update the DataSet. It is critical that
everything is done
' in the proper sequence, unless you turn off the EnforceConstraints
property. ' So there are two ways of updating the data.
' The first is shutting off EnforceConstraints
inDS.EnforceConstraints = False
Me.sdaProducts.Update(inDS, "Product")
Me.sdaSuppliers.Update(inDS, "Supplier") Catch exc As Exception
' Alert the front end that an error occurred.
RaiseEvent ConnectionFailure("Unable to update the data source.")
End Try
End Sub Kindly let me know what could be the probable cause for the problem.
Thanks and Regards,
M.R.Sreenivas
TCS
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]