处理数据库函数
来源:互联网 发布:想开淘宝店卖什么好 编辑:程序博客网 时间:2024/05/16 07:55
<!-- /* Font Definitions */ @font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;}@font-face{font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;mso-font-charset:1;mso-generic-font-family:roman;mso-font-format:other;mso-font-pitch:variable;mso-font-signature:0 0 0 0 0 0;}@font-face{font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;mso-font-charset:0;mso-generic-font-family:swiss;mso-font-pitch:variable;mso-font-signature:-1610611985 1073750139 0 0 159 0;}@font-face{font-family:"/@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-unhide:no;mso-style-qformat:yes;mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;mso-pagination:none;font-size:10.5pt;mso-bidi-font-size:11.0pt;font-family:"Calibri","sans-serif";mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;mso-font-kerning:1.0pt;}.MsoChpDefault{mso-style-type:export-only;mso-default-props:yes;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page{mso-page-border-surround-header:no;mso-page-border-surround-footer:no;}@page Section1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:36.0pt;mso-footer-margin:36.0pt;mso-paper-source:0;}div.Section1{page:Section1;}-->
处理数据库中数据常用的一个函数:
Public Function ExecuteSQL(ByVal sql AsString, ByVal msgstring As String) As ADODB.Recordset
Dim cnn As ADODB.Connection (1).定义一个连接
Dimrst As ADODB.Recordset (2).定义一个记录集
Dimstokens() As String
Dimconnectionstring As String
connectionstring = "filedsn=andy.dsn;UID=sa;pwd=123456"
On Error GoTo Executesql_error
stokens() = Split(sql) '将sql中字符串中的每个单词,分别赋给一维数组的每个单位
Set cnn = New ADODB.Connection (3).实例化连接
cnn.Open connectionstring (4).打开连接,让程序连接到特定的数据库
'如果有insert,delete,update语句可以直接执行sql语句而不用去查询,connection,command,recordset都可以执行sql语句
If InStr("INSERT,DELETE,UPDATE", UCase$(stokens(0))) Then
cnn.Execute sql (5).执行sql语句(update,delete,insert)
msgstring = stokens(0) & "query sucessfully!" ‘执行成功!
Else
'查询记录集,并且返回记录集
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient '远程数据服务用法 当用于客户端 (ADOR)Recordset 或 Connection 对象时,只能将 CursorLocation 属性设置为 adUseClient。
rst.Open Trim$(sql), cnn, adOpenKeyset, adLockOptimistic(6).select语句返回一个记录集(rst),rst.open “select* from student _info”,cnn,adopenkeyset,adlockoptimistic
'打开一个数据库元素,此元素可提供对表的记录、查询的结果或保存的 Recordset 的访问。
Set ExecuteSQL = rst
msgstring = "查询到" & rst.RecordCount & "条记录"
End If
Executesql_exit:
Set rst = Nothing
Set cnn = Nothing
Exit Function
Executesql_error:
msgstring = "查询错误:" & Err.decription
Resume Executesql_exit
- 处理数据库函数
- 通用数据库处理函数
- mysql数据库字符处理函数
- MYSQL数据库常用字符处理函数
- ASP对数据库执行函数,利用数组处理.
- SQL数据库函数如何对多结果进行循环处理
- sqlite数据库处理时间问题 和 日期时间函数
- SQLite数据库用来处理锁定情况的两个函数
- oracle数据库多级树查询及特殊处理函数
- 数据库 SUM + AVG 等聚合函数 结果为NULL 处理
- pgsql数据库和PHP中日期、时间戳处理函数
- SqlServer数据库-日期转换处理函数,非常强大
- netezza 数据库几个常用的日期处理函数
- 数据库处理
- 数据库——sql中的NULL值处理函数及其他常用函数
- 数据库 函数
- 数据库函数
- 数据库-函数
- datagridview数据导入Excel
- datagridview数据导入Excel
- 在软件中加入Forcal & MForcal支持
- 123
- 由硬件原因引起的电脑自动关机
- 处理数据库函数
- linux自学之旅_前章
- 最想挖的各家互联网公司最牛职位人才
- C++中声明托管对象
- 使用报表grid++report
- C#跨库增删改事务控制
- 自动关机故障排除方法
- 主板常见故障诊断方法(主板故障可导致断电关机故障)
- 将Vmware虚拟机添加成为系统服务