vb equivalent ?

J

Jon Paal

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

"using (SQLiteTransaction mytransaction = myconnection.BeginTransaction())"
 
M

Mischa Kroon

If I'm not mistaking:
dim mytransaction as SQLiteTransaction = myconnection.BeginTransaction()
 
T

ThunderMusic

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
 
G

Guest

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
 
C

Cowboy \(Gregory A. Beamer\)

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.
 
T

ThunderMusic

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
 
J

Jon Paal

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
 
C

Cowboy \(Gregory A. Beamer\)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top