从DataGridView编辑数据 [英] Edit Data from DataGridView

查看:103
本文介绍了从DataGridView编辑数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我想问你们如何在数据库(VB)中编辑Gridview中的现有数据?请帮帮我。

谢谢。

我正在尝试这个:

gridview显示已完成,但在更新了行的数据后,我我收到确认的MsgBox,但没有在数据库中更新数据

Here I want to ask you guys how to edit existing data from Gridview in database(VB)? Please help me.
Thank You.
I am trying this:
The gridview display is done, but after updating the row's data, I am getting the MsgBox of confirmation but not getting the data updated in database

Imports System.Data.SqlClient
Public Class attendance
    Dim cmd As New SqlCommand
    Dim ad As New SqlDataAdapter("select mem_roll_no ,mem_surname ,mem_f_name ,mem_l_name ,mem_mno ,mem_batch ,mem_status from attendance_master", login.cn)
    Private Sub attendance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        Dim ds As New DataSet
        ad.Fill(ds)
        ds.Tables(0).AcceptChanges()
        If ds.Tables(0).Rows.Count > 0 Then
            DataGridView1.DataSource = ds.Tables(0)
        Else
            DataGridView1.DataSource = Nothing
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim build As New SqlCommandBuilder(ad)
        Dim dt As New DataTable
        ad.Update(dt)
        MsgBox("Success!!!")
    End Sub
End Class

推荐答案

检查一下:

VB.net:如何从datagridview更新数据库 [ ^ ]


这篇关于从DataGridView编辑数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆