当前位置:网站首页>How to read excel table to database
How to read excel table to database
2022-04-23 08:53:00 【lse2019】
Method 1 : Use SQL sentence .
private _ Connection string = “ODBC;DBQ=” + my excel file + “;Driver={Driver do Microsoft Excel(*.xls)};”
. Subroutines Read external data to advanced tables , , Open . Parameters ginseng _ Connection string , The text type , , connstr. Parameters ginseng _SQL Query statement , The text type . Parameters ginseng _ Advanced forms , Advanced forms . local variable private _ Database connection 1, Database connection object . local variable private _ Recordset 1, Recordset objects . local variable private _ Temporary text , The text type . local variable i, Integer type . local variable j, Integer parameter _ Advanced forms . Row number = 1' One 、ADO Connect private _ Database connection 1.conn Set connection string ( ginseng _ Connection string ) ' (1) Set connection string . If ( private _ Database connection 1.conn open () = really ) ' (2) Connection open ' Two 、ADO Recordset private _ Recordset 1.rs Set active connection ( private _ Database connection 1.conn Take the connection object itself ()) ' (1) Set recordset connection private _ Recordset 1.rs Set data source ( ginseng _SQL Query statement ) ' (2) Set recordset data source . If ( private _ Recordset 1.rs open () = really ) ' (3) Open recordset ginseng _ Advanced forms . Number of columns = private _ Recordset 1.rs Number of fields () + 1 . Cycle head ( private _ Recordset 1.rs Number of fields () + 1, i) ginseng _ Advanced forms . Set data (0, 0, # Table constant . The text type , “ Serial number ”) ginseng _ Advanced forms . Set data (0, i, # Table constant . The text type , private _ Recordset 1.rs Take the field name (i - 1)) ' Debug output ( private _ Recordset 1.rs Get the field type (i - 1)) . Cycle end () i = 1 ginseng _ Advanced forms . visual = false . Judge the beginning of the loop ( private _ Recordset 1.rs After the last record () = false ) ginseng _ Advanced forms . Insert row (, ) ginseng _ Advanced forms . Set data (i, 0, # Table constant . The text type , i) . Cycle head ( private _ Recordset 1.rs Number of fields (), j) ginseng _ Advanced forms . Set data (i, j, # Table constant . The text type , private _ Recordset 1.rs Read the text ( private _ Recordset 1.rs Take the field name (j - 1))) .' If it's true ( private _ Recordset 1.rs Take the field name (j - 1) = “ Project code ”) ' Debug output ( private _ Recordset 1.rs Read the text ( private _ Recordset 1.rs Take the field name (j - 1))) . If it really ends . Cycle end () private _ Recordset 1.rs Move to next () i = i + 1 . Judge the end of the loop () ginseng _ Advanced forms . visual = really private _ Recordset 1.rs close () ' Close the current recordset . otherwise Message box (“ Failed to open recordset .” + To text ( private _ Recordset 1.rs Take the State ()), 16 + 0, “ Tips ”) . If the end of the private _ Database connection 1.conn close () ' disconnect Advanced forms _ Alternate color display ( ginseng _ Advanced forms ). otherwise Message box (“ Failed to connect to data source .”, 16 + 0, “ Tips ”). If the end of the
版权声明
本文为[lse2019]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230816296499.html
边栏推荐
- 洋桃電子STM32物聯網入門30步筆記一、HAL庫和標准庫的區別
- 请提前布局 Star Trek突破链游全新玩法,市场热度持续高涨
- 错误: 找不到或无法加载主类
- 1099 establish binary search tree (30 points)
- 政务中台研究目的建设目标,建设意义,技术创新点,技术效果
- Chris LATTNER, father of llvm: the golden age of compilers
- Reference passing 1
- Go language self-study series | initialization of golang structure
- DJ音乐管理软件Pioneer DJ rekordbox
- Illegal character in scheme name at index 0:
猜你喜欢

Enterprise wechat application authorization / silent login

L2-3 romantic silhouette (25 points)

Star Trek强势来袭 开启元宇宙虚拟与现实的梦幻联动

Share the office and improve the settled experience

Notes on 30 steps of introduction to Internet of things of yangtao electronics STM32 III. Explanation of new cubeide project and setting

L2-022 重排链表 (25 分)(map+结构体模拟)

2022-04-22 openebs cloud native storage

Test your machine learning pipeline

PCTP考试经验分享

valgrind和kcachegrind使用運行分析
随机推荐
资源打包关系依赖树
Search tree judgment (25 points)
BK3633 规格书
Go语言自学系列 | golang结构体的初始化
Harbor企业级镜像管理系统实战
valgrind和kcachegrind使用运行分析
洋桃電子STM32物聯網入門30步筆記一、HAL庫和標准庫的區別
idea打包 jar文件
1099 建立二叉搜索树 (30 分)
玩转二叉树 (25 分)
Illegal character in scheme name at index 0:
【IndexOf】【lastIndexOf】【split】【substring】用法详解
Automatic differentiation and higher order derivative in deep learning framework
Noyer électronique stm32 Introduction à l'Internet des objets 30 étapes notes I. différences entre la Bibliothèque Hal et la Bibliothèque standard
Failed to prepare device for development
Bk3633 specification
Withholding agent
PLC的点表(寄存器地址和点表定义)破解探测方案--方便工业互联网数据采集
Test your machine learning pipeline
Redis Desktop Manager for Mac(Redis可视化工具)