Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

VB.Net2008, SQL Server 2005

Thankx for your suggestions. My Data Base is stored on a server computer and clients are accessing that db. What i am doing is i retrieve data in a data set. Code is as follows


VB
Protected Function ExecuteDQL(ByVal Query As String) As DataSet
        DS = New DataSet
        DBCom = DBCon.CreateCommand()        
        DBAdp = New SAS.SqlDataAdapter
        Try
            DBCom.CommandText = Query
            DBCom.Connection = DBCon
            DBAdp.SelectCommand = DBCom
            DBAdp.Fill(DS)
            If DS.Tables(0).Rows.Count >= 1 Then
                Return DS
            Else
                Return Nothing
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
            Return Nothing
        Finally
            CloseDB()
        End Try
    End Function


What i am confused about is if 3 users access same data in same time and one of those changes data in the meanwhile then other 2 will be dealing with old data rather than the new one. Please Help me in this regard.

Thankx
Posted
Updated 15-Mar-10 0:53am
v2

why not but why to use? It will have no meaning!

In terms of Transact-SQL, there are three importance commands to manage a transaction. BEGIN TRANSACTION will begin a transaction, COMMIT TRANSACTION will commit the transaction to the database, and ROLLBACK TRANSACTION will roll the transaction back.

Retrieving data means, you are selecting something. When you are selecting something you are NOT MODIFYING any data. Thus, no role of COMMIT or ROLLBACK.

In case, you are inserting, updating something in a transaction and also want to retrieve something the moment they are inserted/updated/deleted then putting a select will mean something in a transaction.

You don't need to do anything extra for it. Just place your commands in between BEGIN & END tag of transaction, COMMIT it or ROLLBACK.

Hope its clear.

Incase needed, read these for more info:
TRANSACTION SQL Sample[^]
SqlTransaction Class[^]
TRY...CATCH (Transact-SQL)[^]
 
Share this answer
 
Hi,
if you explain what are you trying to do ,
maybe we can help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900