C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to Lock a Table in SQL SERVER Using VB.NET


Posted Date: 05 Jun 2008    Resource Type: Code Snippets    Category: VB.NET Syntax
Author: GopiMember Level: Bronze    
Rating: Points: 10



The following code shows how to Lock a Table in SQL SERVER Using VB.NET

Step1:Create Window based project and select language as VB.NET
Step2:Add a button control named CmdFill set its properties Text="Fill" and a datagrid named Datagrid1
Step3:Implement the following Code


Dim txn As SqlTransaction
Dim ds As New DataSet
Dim con As New SqlConnection("Data source=sourcename;Initial catalog=Northwind;uid=gopi;pwd=gopi")
Private Sub CmdFill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdFill.Click
con.Open()
adp.Fill(ds, "Customers")
txn = con.BeginTransaction(IsolationLevel.RepeatableRead)
adp.SelectCommand.Transaction = txn
adp.Fill(ds)
DataGridView1.DataSource = ds
DataGridView1.DataMember = "Customers"
End Sub

Step 4: Run the program and click the Fill Button.Datagrid will be filled with customers table.
Step 5:Go to SQL server.Select query analyzer and run this query
update customers set contactname='Gopi' where contactname='Antonio Moreno'
Step 6:You will find the query executing with out doing any changes until you close your application form.




Responses

Author: Kapil Dhawan    18 Jun 2008Member Level: Gold   Points : 2
Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code will help lots of guys
Thanks to you
Regards,
Kapil



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to change upper case of 'cmbobox' in vb.net
Previous Resource: reading / writing Cookies in .net
Return to Discussion Resource Index
Post New Resource
Category: VB.NET Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use