全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Dim Conn As ADODB.Connection Set Conn = New ADODB.Connection Conn.Open 连接到你的数据库XJGL.MDB的字符串 Conn.Execute select * into tmptable from excel 8.0;database= + 你的excel表名 + .sheet名$ Conn.Execute insert into xsda(学籍号,准考证号,姓名,性别,出生年月,班级)select 学籍号,准考证号,姓名,性别,出生年月,班级 from tmptable Conn.Execute drop tabel tmptable Set Conn = Nothing/Sub LoadUsers() On Error Resume Next Screen.MousePointer = 11 Dim xlspath As String Dim xlsConn As New ADODB.Connection Dim xlsrs As New ADODB.Recordset Dim sql As String Dim totalRecords As Long xlspath = Text1 sql = select * from Sheet1$ With xlsConn .ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source= & xlspath & ;Extended Properties=Excel 8.0;HDR=Yes;IMEX=1; .CommandTimeout = 5 .Open End With xlsrs.Open sql, xlsConn, adOpenStatic, adLockReadOnly totalRecords = xlsrs.RecordCount ProgressBar1.Max = totalRecords ProgressBar1.Min = 0 ProgressBar1.Value = 0 Conn.Execute delete from Users Dim i As Long For i = 0 To totalRecords - 1 Conn.Execute insert into Users (ID,Name,Shenfennums,Address) values( & xlsrs(工号) & , & xlsrs(员工名称) & , & xlsrs(身份证号码) & , & xlsrs(地址) & ) ProgressBar1.Value = ProgressBar1.Value + 1 xlsrs.MoveNext Next xlsrs.Close Set xlsrs = Nothing xlsConn.Close Screen.MousePointer = 0 Unload Me End Sub/Dim extend_str As String Dim execl_cnn As New ADODB.Connection Dim execl_rst As New ADODB.Recordset Dim execl_count_rst As New ADODB.Recordset 纪录数量 Dim execl_field_rst As New ADODB.Recordset Dim execl_strconn As String Dim execl_strcmd As String Dim execl_count_str As String Dim insertStr As String 操作oracle数据库的记录集 Dim rst As ADODB.Recordset CommonDialog1.ShowOpen extend_str = Right(CommonDialog1.FileName, 3) If (extend_str = xls) Then execl_cnn.Open Provider=Microsoft.Jet.OLEDB.4.0; & _ Data Source= & CommonDialog1.FileName & _ ;Extended Properties=Excel 8.0; ElseIf (extend_str = dbf) Then execl_cnn.ConnectionString = Provider=MSDASQL.1;Driver=Microsoft Visual Foxpro Driver;SourceType=DBF;DBQ= & getDir(CommonDialog1.FileName) execl_cnn.Open End If If (extend_str = xls) Then execl_strcmd = SELECT * from Sheet1$ execl_count_str = SELECT count(*) from Sheet1$ execl_field_rst.Open execl_count_str, execl_cnn If (execl_field_rst.Fields(0).Value = 0) Then execl_strcmd = SELECT * from & getFileNoExt(getfile(CommonDialog1.FileName) & $ execl_count_str = SELECT count(*) from & getFileNoExt(getfile(CommonDialog1.FileName) & $ End If execl_field_rst.Close ElseIf (extend_str = dbf) Then execl_strcmd = SELECT * from & CommonDialog1.FileName execl_count_str = SELECT count(*) from & CommonDialog1.FileName End If execl_rst.Open execl_strcmd, execl_cnn execl_count_rst.Open execl_count_str, execl_cnn If (CommonDialog1.FileName ) Then 进度条设置 ProgressBar1.Min = 0 ProgressBar1.max = execl_count_rst.Fields(0).Value If (execl_rst.RecordCount) Then 如果有记录 If (Option1.Value) Then 如果是仪器总库 If (execl_rst.Fields.Count = 8) Then Set rst = yg_gain_table_recordset(yg_device) execl_rst.MoveFirst Do While (Not execl_rst.EOF) rst.AddNew rst.Fields(0).Value = yg_getNextId(yg_device_id) rst.Fields(1).Value = execl_rst.Fields(0).Value & rst.Fields(2).Value = execl_rst.Fields(1).Value & rst.Fields(3).Value = execl_rst.Fields(2).Value & rst.Fields(4).Value = execl_rst.Fields(3).Value & rst.Fields(5).Value = execl_rst.Fields(4).Value & rst.Fields(6).Value = execl_rst.Fields(5).Value & rst.Fields(7).Value = execl_rst.Fields(6).Value & rst.Fields(8).Value = execl_rst.Fields(7).Value & rst.Update execl_rst.MoveNext ProgressBar1.Value = ProgressBar1.Value + 1 DoEvents Loop yg_free_recordset rst Else MsgBox 结构不一致 Exit Sub End If End If If (Option2.Value) Then 如果是外借仪器 If (execl_rst.Fields.Count = 12) Then Set rst = yg_gain_table_recordset(yg_out_device) execl_rst.MoveFirst Do While (Not execl_rst.EOF) rst.AddNew rst.Fields(0).Value = yg_getNextId(yg_out_device_id) rst.Fields(1).Value = execl_rst.Fields(0).Value & rst.Fields(2).Value = execl_rst.Fields(1).Value & rst.Fields(3).Value = execl_rst.Fields(2).Value & rst.Fields(4).Value = execl_rst.Fields(3).Value & rst.Fields(5).Value = execl_rst.Fields(4).Value & rst.Fields(6).Value = execl_rst.Fields(5).Value & rst.Fields(7).Value = execl_rst.Fields(6).Value & rst.Fields(8).Value = execl_rst.Fields(7).Value & rst.Fields(9).Value = execl_rst.Fields(8).Value & rst.Fields(10).Value = execl_rst.Fields(9).Value & rst.Fields(11).Value = ex
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 职称申报系统个人申报资料填写的指南
- 无人驾驶汽车的伦理困境、成因及对策分析
- 工程监理合同知识点(3篇)
- 基本养老保险基金投资管理困境及策略
- 大连理工大学本科毕业设计(论文)模板(2025年12月修订)
- 安检作业标准落实不到位的原因分析
- 分析学生学习困难的原因
- 浅论高铁站房节能减排之断热稀土热障涂层王玉波
- 社会工作的价值观 冲突及对策
- 试论说一切有部“有”与“三世”的确立
- 宠物行业直播带货合作协议
- GB/T 20977-2024糕点质量通则
- 2023年上海交响乐团招聘工作人员考试真题
- 网络总编辑负责制度
- 医务人员职业暴露预防及处理课件(完整版)
- 百年孤独名著导读模板
- 10以内加减法(10000题)
- RB/T 140-2023空中乘务教育培训服务认证要求
- DZ∕T 0348-2020 矿产地质勘查规范 菱镁矿、白云岩(正式版)
- (正式版)JTT 1499-2024 公路水运工程临时用电技术规程
- 《即兴口语表达》课件
评论
0/150
提交评论