本文介绍了如何在VB.NET中保存gridview数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有网格视图,它将一个表名的内容数据作为empdata,我在网格视图列中放置了复选框。现在我必须将网格视图中可用的数据存储到另一个表名作为出勤。我不明白在插入查询中使用哪种值。请帮忙。 以下是我的gridview代码 私人 Sub filldata() Dim cmd 正如 新 OleDbCommand Dim dr 作为 OleDbDataReader cmd.Connection = cn cmd.CommandText = 通过empid选择empid,fname,empdata命令中的指定 dr = cmd.ExecuteReader Dim dt As 新 DataTable dt.Load(dr) grd.DataSource = dt dt .Dispose() 如果 dr.IsClosed = False 然后 dr.Close() grd.Columns( 0 )。HeaderText = Emp Id grd.Columns( 1 )。HeaderText = Emp Name grd.Columns( 2 )。HeaderText = 名称 grd.Columns.Add(grdchk ) grd.Columns( 3 )。HeaderText = Attandance grdchk.ThreeState = True grd.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill 结束 Sub 现在我不知道哪个使用价值 私有 Sub btnsave_Click(发件人作为系统。 Object ,e As System.EventArgs) Handles btnsave 。点击 Dim cmd 作为 新 OleDbCommand grdchk = IIf(CheckState.Checked, Present, 缺席) cmd.Connection = cn cmd.CommandText = 插入到attndance值( 结束 Sub 我的尝试: i不知道该尝试什么。 :)解决方案 请在此处查看答案:如何保存GridView DataBase中的数据使用Vb.net [ ^ ] i have grid view and it content data from one table name as empdata and i have put check box in grid view column. now i have to store the data which is available in grid view to another table name as attendance. i don't understand which kind of value to have use in insert query. please help. following is my code for gridviewPrivate Sub filldata() Dim cmd As New OleDbCommand Dim dr As OleDbDataReader cmd.Connection = cn cmd.CommandText = "select empid,fname,designation from empdata order by empid" dr = cmd.ExecuteReader Dim dt As New DataTable dt.Load(dr) grd.DataSource = dt dt.Dispose() If dr.IsClosed = False Then dr.Close() grd.Columns(0).HeaderText = "Emp Id" grd.Columns(1).HeaderText = "Emp Name" grd.Columns(2).HeaderText = "Designation" grd.Columns.Add(grdchk) grd.Columns(3).HeaderText = "Attandance" grdchk.ThreeState = True grd.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill End Suband now i don't know which value to have usePrivate Sub btnsave_Click(sender As System.Object, e As System.EventArgs) Handles btnsave.Click Dim cmd As New OleDbCommand grdchk = IIf(CheckState.Checked, "Present", "Absent") cmd.Connection = cn cmd.CommandText = "insert into attandance values(" End SubWhat I have tried:i don't know what to have try. :) 解决方案 See the answers here: How TO Save GridView Data In DataBase using Vb.net[^] 这篇关于如何在VB.NET中保存gridview数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-27 13:50