database and vb issue

  • 13 years ago
    Hi everyone:

    Im trying to do something in VB and Oracle and i need help implementing a transaction (2 tables must be updated or non).

    Can anyone post some example code about how to do so?

    Thank you very much


  • 13 years ago

    Hi Men !!

            I will tell u how to implement trnasctions using sql server. U can do the same by changing the realavant data types to oracle.


    m_Cnn As new SqlClient.SqlConnection   // connection variable


    m_Cmd As SqlClient.SqlCommand   // command object

    Private m_Tran As SqlClient.SqlTransaction   // transaction object

    m_Cnn.ConnectionString = <connection string goes here>

    m_Cmd = m_Cnn.CreateCommand


    m_Tran = m_Cnn.BeginTransaction

    m_Cmd.Transaction = m_Tran

    m_Cmd.CommandText = < Sql statement >  // 1st set

    m_Cmd.ExecuteNonQuery() // 1st set

    m_Cmd.CommandText = < Sql statement >  //  2nd set

    m_Cmd.ExecuteNonQuery() // 2 nd set



    Above is the code for handling transactions. I something goes wrong while excuting the commands, you can catch that and rollback the transaction.

    Hope this will help to solve ur problem !!

  • 13 years ago
    Thanks a lot, it sure helps :)

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We better hurry up and start coding, there are going to be a lot of bugs to fix.”