Ado.Recordset.fields("列名").value=值
然后
Ado.recordset.update
添加:’下面这句连接数据库指定表的所有字段
Adodc1.RecordSource = "select * from 库存表"
’下面这句添加记录
Adodc1.Recordset.AddNew
下面4句就是通过4个TEXTBOX控件输入字段的数据,如果是数字类型可以加VAL
Adodc1.Recordset.Fields("货物编号") = Text1.Text
Adodc1.Recordset.Fields("货物名称") = Text2.Text
Adodc1.Recordset.Fields("库存量") = Text3.Text
Adodc1.Recordset.Fields("单位") = Text4.Text
’下面这个是修改后更新
Adodc1.Recordset.Update
修改:
'通过主键指定要修改的记录
Adodc1.RecordSource = "select * from 库存表 where 货物编号 = " &Text1.Text
Adodc1.Refresh
Adodc1.Recordset.Fields("货物编号") = Text1.Text
Adodc1.Recordset.Fields("货物名称") = Text2.Text
Adodc1.Recordset.Fields("库存量") = Text3.Text
Adodc1.Recordset.Fields("单位") = Text4.Text
1你是不是用DATAGRID显示个recordset的~用addnew添加数据应该是可以直接更新的啊
2
用个recordset执行个统计的SQL语句后或者合计结果
比如用下面代码打开个recordset
select sum(num) as 合计 from books
则
rs.fields("合计")就是num这列的总合
然后在按照你程序要求计算
3
打开recordset的时候用别名
select username as 用户名 from usertable
这样就是显示中文列名了
4
Set cmdstr = New ADODB.Command
cmdstr.ActiveConnection = conn (ADODB.Connection的名)
cmdstr.CommandText = str_sql (SQL语句)
str_sql="update usertable set name='abc' where id=123"
cmdstr.CommandType = adCmdText
cmdstr.Execute (执行update usertable set name='abc' where id=123)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)