vb equivalent ?

  • Thread starter Thread starter Jon Paal
  • Start date Start date
J

Jon Paal

what is vb equivalent to this C# code ?
converters failed to handle this

"using (SQLiteTransaction mytransaction = myconnection.BeginTransaction())"
 
If I'm not mistaking:
dim mytransaction as SQLiteTransaction = myconnection.BeginTransaction()
 
there's no equivalent (as far as I know) for a C# using in VB... the C#
using creates the object and disposes it at the end and VB using is just for
shortcuts... There's not relation at all between the two....

the equivalent would be to dim your variable and dispose it explicitly in
your code when you don't need it anymore...

I hope it helps

ThunderMusic
 
There is certainly an equivalent in either 2003 or 2005:
2005:
Using mytransaction As SQLiteTransaction = myconnection.BeginTransaction()
2003:
Dim mytransaction As SQLiteTransaction = myconnection.BeginTransaction()
Try
foo
Finally
CType(mytransaction, IDisposable).Dispose()
End Try
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
 
In Framework 2.0, you can use Using.

Using mytransaction As SQLiteTransaction = myconnection.BeginTransaction()

In version 1.1, there is no true equivalent, although you can accomplish the
exact same thing in either 1.1 or 2.0 with this:

Try
Dim mytransaction As SQLiteTransaction = myconnection.BeginTransaction()
Finally
Dim disposableObject as IDisposable = CType(mytransaction, IDisposable)
disposableObject.DIspose()
End Try

Note, however, that casting as IDisposable merely imitates the action of
Using and does not add a real Dispose() method to the class.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
 
the question is... why would you convert a C# project into VB? they are
both alike and C# offers a bit more things over VB... I can't see why
someone would convert a C# project into VB...

ThunderMusic
 
it's not a C# project...


ThunderMusic said:
the question is... why would you convert a C# project into VB? they are both alike and C# offers a bit more things over VB... I
can't see why someone would convert a C# project into VB...

ThunderMusic
 
I was working offline when I wrote and sent as soon as I got hooked back up,
so I did not see your response until today. I will mark that one down. I
also did not test the code, but I am more a C# guy, if that gives me any
points. :-)

More important than the transaction is the connection object, which does
have a Dispose() method and SHOULD be disposed.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
 
Back
Top