C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » DataGridView »

Insertion of more than one record at a time.


Posted Date: 03 Sep 2009    Resource Type: Code Snippets    Category: DataGridView
Author: NeetuMember Level: Diamond    
Rating: 1 out of 5Points: 5



Description :


In this i have created one form that contains one datagrid and one button.
In this user can change multiple records at the same time as well as he can insert or delete multiple recods at the same.


Imports System.Data.OleDb
Public Class Form2

Dim con As New OleDbConnection
Dim str As New System.Text.StringBuilder
Dim cmd As New OleDbCommand
Dim CB As New OleDbCommandBuilder
Dim da As OleDbDataAdapter
Dim dt As New DataTable
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
str.Append("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=")
str.Append(AppDomain.CurrentDomain.BaseDirectory)
str.Append("yogita.mdb")
str.Append(";Persist Security Info=False")
con.ConnectionString = str.ToString
cmd.CommandType = CommandType.Text
cmd.CommandText = "select * from studentDetails "
cmd.Connection = con
da = New OleDbDataAdapter(cmd)
da.Fill(dt)
CB = New OleDbCommandBuilder(da)
DataGridView1.DataSource = dt

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dt.GetChanges()
da.Update(dt)
Msgbox("Records updated in database.")
End Sub
End Class




<img src="c:\one.jpg"gt;


regards
Neetu



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Updation  .  Insertion  .  Deletion of data with datagridview  .  

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: Fetch data from Excel
Previous Resource: Conditional formatting in Datagrid
Return to Discussion Resource Index
Post New Resource
Category: DataGridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use