abhijit
Jun 4th, 2001, 09:30 AM
Hi Everyone,
i would like you to solve this mts mystery for me.
this is my function as copied from MSDN Code Center.
Public Function DoStuffBad() As Variant
On Error GoTo ErrHandler
Dim oConn As New ADODB.Connection
Dim oCmd As New ADODB.Command
Dim oRS As ADODB.Recordset
Dim sTemp As String
Dim cNString As String
cNString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb;Persist Security Info=True"
oConn.Open cNString
Set oCmd.ActiveConnection = oConn
oCmd.CommandText = "SELECT * FROM Authors"
oCmd.CommandType = adCmdText
Set oRS = oCmd.Execute
Do While Not oRS.EOF
sTemp = sTemp & ";" & oRS.Fields(1)
oRS.MoveNext
Loop
'This FAILS if executed within an MTS transaction with ADO 'Unspecified Error' message:
oConn.Execute "INSERT INTO Authors (Author, [Year Born]) values ('Dr Dolittle',1925)"
GetObjectContext.SetComplete
DoStuffBad = "Worked ok" & " " & sTemp
Exit Function
ErrHandler:
GetObjectContext.SetAbort
Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext
DoStuffBad = Err.Description
End Function
My project has the necessary references added. However the function does not work.
Could anyone care to highlight why?
Regards,
Abhijit
i would like you to solve this mts mystery for me.
this is my function as copied from MSDN Code Center.
Public Function DoStuffBad() As Variant
On Error GoTo ErrHandler
Dim oConn As New ADODB.Connection
Dim oCmd As New ADODB.Command
Dim oRS As ADODB.Recordset
Dim sTemp As String
Dim cNString As String
cNString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Biblio.mdb;Persist Security Info=True"
oConn.Open cNString
Set oCmd.ActiveConnection = oConn
oCmd.CommandText = "SELECT * FROM Authors"
oCmd.CommandType = adCmdText
Set oRS = oCmd.Execute
Do While Not oRS.EOF
sTemp = sTemp & ";" & oRS.Fields(1)
oRS.MoveNext
Loop
'This FAILS if executed within an MTS transaction with ADO 'Unspecified Error' message:
oConn.Execute "INSERT INTO Authors (Author, [Year Born]) values ('Dr Dolittle',1925)"
GetObjectContext.SetComplete
DoStuffBad = "Worked ok" & " " & sTemp
Exit Function
ErrHandler:
GetObjectContext.SetAbort
Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext
DoStuffBad = Err.Description
End Function
My project has the necessary references added. However the function does not work.
Could anyone care to highlight why?
Regards,
Abhijit