当前位置:网站首页>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
边栏推荐
- Multi view depth estimation by fusing single view depth probability with multi view geometry
- BK3633 规格书
- L2-024 tribe (25 points) (and check the collection)
- Reference passing 1
- bashdb下载安装
- Illegal character in scheme name at index 0:
- Non duplicate data values of two MySQL query tables
- L2-023 图着色问题 (25 分)(图的遍历)
- Introduction to matlab
- 关于数组复制问题
猜你喜欢
idea底栏打开services
Brief steps to build a website / application using flash and H5
valgrind和kcachegrind使用运行分析
Yangtao electronic STM32 Internet of things entry 30 step notes II. Cube ide download, installation, sinicization and setting
Get the absolute path of the class according to the bytecode
Please arrange star trek in advance to break through the new playing method of chain tour, and the market heat continues to rise
bashdb下载安装
MATLAB入门资料
汇编语言与逆向工程 栈溢出漏洞逆向分析实验报告
在sqli-liabs学习SQL注入之旅(第十一关~第二十关)
随机推荐
2021 Li Hongyi's adaptive learning rate of machine learning
Download and install bashdb
Latex paper typesetting operation
After a circle, I sorted out this set of interview questions..
LeetCode396.旋转数组
Go language self-study series | golang structure pointer
MATLAB 画五星红旗
How much inventory recording does the intelligent system of external call system of okcc call center need?
洋桃电子STM32物联网入门30步笔记二、CubeIDE下载、安装、汉化、设置
Star Trek强势来袭 开启元宇宙虚拟与现实的梦幻联动
Restore binary tree (25 points)
Please arrange star trek in advance to break through the new playing method of chain tour, and the market heat continues to rise
Find the sum of simple types of matrices
使用flask和h5搭建网站/应用的简要步骤
Get the absolute path of the class according to the bytecode
Test your machine learning pipeline
cadence的工艺角仿真、蒙特卡洛仿真、PSRR
mycat配置
Valgrind and kcache grind use run analysis
Idea package jar file