标题:dateGrid编辑数据的问题
只看楼主
zjhm
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2006-4-12
 问题点数:0 回复次数:1 
dateGrid编辑数据的问题

我想在DATEGRID里面编辑数据进行更新,在属性生成器里面应该怎么设置啊,谁有这方面的资料,发一个看看,感谢啊!!!

搜索更多相关主题的帖子: 数据 dateGrid 
2006-06-07 09:38
mylovemin
Rank: 1
等 级:新手上路
帖 子:37
专家分:0
注 册:2006-6-6
得分:0 

在更新的时间中

Dim objcmd As OleDbCommand
Dim TextBoxInGrid As TextBox
Dim newXingming, newzhiwei, newjianjie, newxueli, newsex, newqita, newlianxi As String
Dim strUpdate As String = "update zhaoping set 公司=@newXingming,职位=@newzhiwei,工作简介=@newjianjie,学历=@newxueli,要求性别=@newsex,其他要求=@newqita,联系方式=@newlianxi where ID=" & DataGrid1.DataKeys(e.Item.ItemIndex)
TextBoxInGrid = CType(e.Item.Cells(0).Controls(0), TextBox)
newXingming = TextBoxInGrid.Text

TextBoxInGrid = CType(e.Item.Cells(1).Controls(0), TextBox)
newzhiwei = TextBoxInGrid.Text

TextBoxInGrid = CType(e.Item.Cells(2).Controls(0), TextBox)
newjianjie = TextBoxInGrid.Text

TextBoxInGrid = CType(e.Item.Cells(3).Controls(0), TextBox)
newxueli = TextBoxInGrid.Text

TextBoxInGrid = CType(e.Item.Cells(4).Controls(0), TextBox)
newsex = TextBoxInGrid.Text

TextBoxInGrid = CType(e.Item.Cells(5).Controls(0), TextBox)
newqita = TextBoxInGrid.Text

TextBoxInGrid = CType(e.Item.Cells(6).Controls(0), TextBox)
newlianxi = TextBoxInGrid.Text

Dim conn As OleDbConnection
conn = New System.Data.OleDb.OleDbConnection("Provider= Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("database\wz.mdb"))
conn.Open()
objcmd = New OleDbCommand(strUpdate, conn)
objcmd.Parameters.Add("@newXingming", OleDbType.VarChar)
objcmd.Parameters("@newXingming").Value = newXingming

objcmd.Parameters.Add("@newzhiwei", OleDbType.VarChar)
objcmd.Parameters("@newzhiwei").Value = newzhiwei

objcmd.Parameters.Add("@newjianjie", OleDbType.VarChar)
objcmd.Parameters("@newjianjie").Value = newjianjie

objcmd.Parameters.Add("@newxueli", OleDbType.VarChar)
objcmd.Parameters("@newxueli").Value = newxueli

objcmd.Parameters.Add("@newsex", OleDbType.VarChar)
objcmd.Parameters("@newsex").Value = newsex

objcmd.Parameters.Add("@newqita", OleDbType.VarChar)
objcmd.Parameters("@newqita").Value = newqita

objcmd.Parameters.Add("@newlianxi", OleDbType.VarChar)
objcmd.Parameters("@newlianxi").Value = newlianxi

objcmd.ExecuteNonQuery()
conn.Close()

DataGrid1.EditItemIndex = -1
bindData()

2006-06-07 10:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-70288-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.302602 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved