Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2007, 02:52 AM
Authorized User
 
Join Date: May 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jazzydonald
Default How do i Update data through a datagridview

Hi,
I have a data grid that gets data from one table in the database. I want to allow users to be able to update,add,or delete records via datadridview and update the changes to the database.How do i do that.

Here is my code that popualte the grid with data.

Private Sub PopulateGrid()

Dim ObjConn As New SqlConnection("server=(local);database=NHIF;Integr ated security=true")
        Dim objDataAdapter As New SqlDataAdapter("select * from currentID", ObjConn)
        'Try

        objDataAdapter.SelectCommand = New SqlCommand
        objDataAdapter.SelectCommand.Connection = ObjConn
        objDataAdapter.SelectCommand.CommandText = "select DFname,DLname,Gender,MembershipNo,IssuedDate,Typeo fCard,BirthDate from currentID where CHECKNO='" & Trim(txtCheckNo.Text) & "'"
        objDataAdapter.SelectCommand.CommandType = CommandType.Text
        ObjConn.Open()

        objDataAdapter.Fill(objDataset, "currentID")
        ObjConn.Close()

        CURRENTIDDataGridView.DataSource = objDataset
        CURRENTIDDataGridView.DataMember = "currentID"


        objDataAdapter = Nothing
        ObjConn = Nothing
End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
capture data in datagridview stealthdevil Visual Basic 2005 Basics 0 January 23rd, 2008 06:49 PM
Update Data in Datagridview munmin2000 Visual Basic 2005 Basics 1 November 5th, 2007 03:27 AM
update datagridview ami23 VB.NET 2002/2003 Basics 2 April 27th, 2007 11:59 PM
DataGridView Update Problem bipulbasakdhaka Visual Basic 2005 Basics 0 November 6th, 2006 04:31 AM
Update a DataGridView without CommandBuilder sfx ADO.NET 1 August 4th, 2006 05:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.