Function CreatSelectionHeading(RstFiledsName As Variant) As ADODB.Recordset
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
With rst
.Fields.Append RstFiledsName(0), adDouble ', 20, adFldIsNullable
.Fields.Append RstFiledsName(1), adDouble ', , adFldMayBeNull
.Fields.Append RstFiledsName(2), adBSTR, , adFldMayBeNull
End With
Set CreatSelectionHeading = rst
End Function 下面的程序,是仿SQL的select * from 表 order by 字段名方法.
nn = Array("x", "y", "tempText")
Set rst = CreatSelectionHeading(nn)
With rst
.Open
For jj = 0 To UBound(mArray)
.AddNew
.Fields(0) = mArray(jj)(0)
.Fields(1) = mArray(jj)(1)
.Fields(2) = mArray(jj)(2)
Next jj
'排序
.Sort = ("x Asc ,y Asc")
在仿select * from 表 order by 字段名 操作时.存在问题是
select * from 表 order by 字段名 每次操作,rst都是全新记录.
上面的程序操作是追加记录.请问各们大侠的问题是,在上面使用中你更喜欢用rst.delete还是set rst =nothing
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
With rst
.Fields.Append RstFiledsName(0), adDouble ', 20, adFldIsNullable
.Fields.Append RstFiledsName(1), adDouble ', , adFldMayBeNull
.Fields.Append RstFiledsName(2), adBSTR, , adFldMayBeNull
End With
Set CreatSelectionHeading = rst
End Function 下面的程序,是仿SQL的select * from 表 order by 字段名方法.
nn = Array("x", "y", "tempText")
Set rst = CreatSelectionHeading(nn)
With rst
.Open
For jj = 0 To UBound(mArray)
.AddNew
.Fields(0) = mArray(jj)(0)
.Fields(1) = mArray(jj)(1)
.Fields(2) = mArray(jj)(2)
Next jj
'排序
.Sort = ("x Asc ,y Asc")
在仿select * from 表 order by 字段名 操作时.存在问题是
select * from 表 order by 字段名 每次操作,rst都是全新记录.
上面的程序操作是追加记录.请问各们大侠的问题是,在上面使用中你更喜欢用rst.delete还是set rst =nothing
解决方案 »
- VB程序不能在VISTA中运行,请问如何修改程序实现VISTA中运行?
- 100分求VB代码,用Des方法加密,实现对字符转换为Byte进行密押后传送数据
- 请教一个打开vb程序遇到的问题。
- 在vb程序中如何将ListView中的数据导出成Excel文件
- 加密文件求教:(解密中文字符时出错,求教高手,谢谢!!!!)
- CSDN的人气怎么这么低呀,谁知道faxcom的用法呀!!
- 请问大家,运用全局Hook来实现程序的热键功能,跟调用API中的GetAsyncKeyState函数来实现程序热键功能,那一个比较好呢?速度那一个更快
- 求教一下关于数据报表的问题!(较多)
- ListView的ReportIcon图像显示位置
- 在VB中可否对POWERPOINT进行调用??
- 透明窗口
- 在VB应用程序中,是把数据放在数据库中用ADO存取快,还是通过函数计算快?
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
所以每次执行下面的
Set rst = CreatSelectionHeading(nn)
时,rst都是个新对象。你用delete还是set =nothing应该都没有影响。
但是考虑到垃圾内存管理,set =nothing是首选。