当前位置:网站首页>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
边栏推荐
- Go语言自学系列 | golang方法
- idea底栏打开services
- php基于哈希算法出现的强弱比较漏洞
- Error: cannot find or load main class
- MATLAB 画五星红旗
- Introduction to matlab
- Single chip microcomputer nixie tube stopwatch
- Stm32f103zet6 [development of standard library functions] - Introduction to library functions
- uni-app和微信小程序中的getCurrentPages()
- 是否完全二叉搜索树 (30 分)
猜你喜欢
经典题目刷一刷
L2-024 部落 (25 分)(并查集)
洋桃电子STM32物联网入门30步笔记四、工程编译和下载
RCC introduction of Hal Library
cadence的工艺角仿真、蒙特卡洛仿真、PSRR
Experimental report on analysis of overflow vulnerability of assembly language and reverse engineering stack
idea打包 jar文件
Notes on 30 steps of introduction to the Internet of things of yangtao electronics STM32 III. cubemx graphical programming and setting the IO port on the development board
1099 建立二叉搜索树 (30 分)
Virtual online exhibition - Online VR exhibition hall realizes 24h immersive exhibition viewing
随机推荐
请问中衍期货安全靠谱吗?
1099 establish binary search tree (30 points)
错误: 找不到或无法加载主类
Stm32f103zet6 [development of standard library functions] - Introduction to library functions
Restore binary tree (25 points)
STM32使用HAL库,整体结构和函数原理介绍
Flink同时读取mysql与pgsql程序会卡住且没有日志
Technological innovation in government affairs in the construction of Digital Government
政务中台研究目的建设目标,建设意义,技术创新点,技术效果
L2-023 图着色问题 (25 分)(图的遍历)
Go语言自学系列 | golang嵌套结构体
Idea import commons-logging-1.2 Jar package
Notes on 30 steps of introduction to the Internet of things of yangtao electronics STM32 III. cubemx graphical programming and setting the IO port on the development board
On time atom joins hands with oneos live broadcast, and the oneos system tutorial is fully launched
Introduction to matlab
Star Trek强势来袭 开启元宇宙虚拟与现实的梦幻联动
RCC introduction of Hal Library
Yangtao electronic STM32 Internet of things entry 30 step notes IV. engineering compilation and download
Concave hull acquisition method based on convex hull of point cloud
求简单类型的矩阵和