当前位置:网站首页>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
边栏推荐
- 微信:获取单个标签所有人
- 【IndexOf】【lastIndexOf】【split】【substring】用法详解
- Yangtao electronic STM32 Internet of things entry 30 step notes IV. engineering compilation and download
- Research purpose, construction goal, construction significance, technological innovation, technological effect
- Illegal character in scheme name at index 0:
- Consensus Token:web3.0生态流量的超级入口
- Go语言自学系列 | golang结构体的初始化
- Talent Plan 学习营初体验:交流+坚持 开源协作课程学习的不二路径
- Latex paper typesetting operation
- How much inventory recording does the intelligent system of external call system of okcc call center need?
猜你喜欢

DJ音乐管理软件Pioneer DJ rekordbox

MySQL小练习(仅适合初学者,非初学者勿进)

Brief steps to build a website / application using flash and H5

Notes d'apprentissage oneflow: de functor à opexprinterpreter

洋桃电子STM32物联网入门30步笔记四、工程编译和下载

L2-022 rearrange linked list (25 points) (map + structure simulation)

Yangtao electronic STM32 Internet of things introduction 30 steps notes 1. The difference between Hal library and standard library

洋桃电子STM32物联网入门30步笔记一、HAL库和标准库的区别

L2-3 浪漫侧影 (25 分)

RCC introduction of Hal Library
随机推荐
爬虫使用xpath解析时返回为空,获取不到相应的元素的原因和解决办法
Initial experience of talent plan learning camp: communication + adhering to the only way to learn open source collaborative courses
rembg 分割mask
Consensus Token:web3.0生态流量的超级入口
Noyer électronique stm32 Introduction à l'Internet des objets 30 étapes notes I. différences entre la Bibliothèque Hal et la Bibliothèque standard
tsdf +mvs
2022-04-22 OpenEBS云原生存储
Go language self-study series | golang structure pointer
Illegal character in scheme name at index 0:
Whether the same binary search tree (25 points)
【IndexOf】【lastIndexOf】【split】【substring】用法详解
OneFlow學習筆記:從Functor到OpExprInterpreter
uni-app和微信小程序中的getCurrentPages()
Error: cannot find or load main class
Summary of solid problems
Non duplicate data values of two MySQL query tables
valgrind和kcachegrind使用运行分析
ESP32程序下载失败,提示超时
Kubernetes如何使用harbor拉去私有镜像
请问中衍期货安全靠谱吗?