|
-
Jun 4th, 2001, 08:30 AM
#1
MTS Mystery
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
-
Jun 5th, 2001, 10:30 AM
#2
Fanatic Member
Code:
Dim oConn As New ADODB.Connection
Dim oCmd As New ADODB.Command
this is your first problem, you must not DIM AS NEW within an MTS transaction, your objects will not get created within context, there are considerations within MTS, I can't detail them here it would take me too long, might help you to read about it on MSDN...
hope this helps...
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Jun 13th, 2001, 09:45 AM
#3
i have got the answer now.
cheers!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|