首先我已经创建了一个表,然后用代码创建字段,名字是不固定的,然后添加数据,第一个添加的字段数据正常,第二个字段数据的位置就不对了,是从最后一行数据开始再次添加~我知道问题大概出在我用了ADDNEW~但是其他方法我实在没想到...大家帮帮忙,谢谢
代码大概是这样的
rs.Open "alter table t add team" + CStr(l ) + " int
rs_u.Open "select * from t"
For i = 0 To List1.ListCount - 1
rs_u.AddNew
rs_u.Fields("team" + CStr(l )) = List1.List(i)
rs_u.Update
Next i
代码大概是这样的
rs.Open "alter table t add team" + CStr(l ) + " int
rs_u.Open "select * from t"
For i = 0 To List1.ListCount - 1
rs_u.AddNew
rs_u.Fields("team" + CStr(l )) = List1.List(i)
rs_u.Update
Next i
解决方案 »
- vb如何调用风格包中的滚动条?
- 函数传递速度问题
- 如何把文件以二进制形式读进数据库?
- 在修改了 RecordSet 的情况下,如何放弃update到数据库关闭RecordSet
- 寻找数据库解密高手
- 100分求一套syris通信协议的说明和有关于syris应用的例子的源代码(最好是VB源码)
- 如何判断另外一个EXE程序的状态
- 关于mis备份和打印的问题,请大哥们支持。急用。。。刚刚没给分
- 把图片存入access数据库,然后再从数据库中取出,有时会失真,不清楚了,大家知道为什么么
- vb HELP!!!!!!!!
- vsFlexGrid能不能实现 这个功能?
- ?如何将选种数据库中的记录生成全新的EXCEL报表?
改成这样试试:
rs_u.Open "select * from t",1,3
这是新增一条,当然会出现以上情况了,
把这一句去掉试试。
字段1 字段2
1111
1111
2222
2222
因為你每增一個字段就AddNew,
只要第一次AddNew就可以了
rs.Open "alter table t add team" + CStr(l ) + " int
rs_u.Open "select * from t"
For i = 0 To List1.ListCount - 1
if l=1 then
rs_u.AddNew
else
rs_u.move i
if rs_u.bof or rs_u.eof then exit for
end ifrs_u.Fields("team" + CStr(l )) = List1.List(i)
rs_u.Update
Next i
rs.Open "alter table t add team" + CStr(l ) + " int
rs_u.Open "select * from t"
For i = 0 To List1.ListCount - 1
if l=1 then
rs_u.AddNew
else
rs_u.move i
if rs_u.bof or rs_u.eof then exit for
end ifrs_u.Fields("team" + CStr(l )) = List1.List(i)
rs_u.Update
Next i
这段代码执行以后,数据库的字段内容不太对,比如输入222,222,111,222
第一组 第二组
222 222
222 222
111
222 111
是这个样子的~