当前位置:网站首页>After the VB.net program is closed, the background is still connected to SQL
After the VB.net program is closed, the background is still connected to SQL
2022-08-09 06:02:00 【CSDN Q&A】
This section writes Excel data into the database in batches, but how can the program still run in the background after closing the program?Is the connection not closed?
For ii = 0 To ListBox1.Items.Count - 1 fileName = ListBox1.Items.Item(ii) Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source='" & fileName & "'; Extended Properties=""Excel 12.0Xml; HDR=Yes""") ExcelConnection.Open() Dim expr As String = "SELECT [PASS_ID] FROM [split details$]" Dim objCmdSelect As OleDbCommand = New OleDbCommand(expr, ExcelConnection) Dim objDR As OleDbDataReader Dim SQLconn As New SqlConnection() Dim ConnString As String = "server=localhost;database=STdata;user id=sa;password=Nngs8888!" SQLconn.ConnectionString = ConnString SQLconn.Open() Using bulkCopy As New SqlBulkCopy(SQLconn) bulkCopy.DestinationTableName = "chaifen"Try objDR = objCmdSelect.ExecuteReader bulkCopy.WriteToServer(objDR) SQLconn.Close() Catch ex As Exception MsgBox(ex.ToString) End Try End Using ExcelConnection.Close() ProgressBar1.Value = ii Next
边栏推荐
猜你喜欢
随机推荐
JVM:(六)运行时数据区之本地方法栈
VScode安装了ESlint以后不管用、不生效的解决办法
Introduction to AIOT
Cysteine/Galactose/Perylenediimide Functionalized Fe3O4 Fe3O4 Nanomaterials | Scientific Research Reagents
qt发送邮件程序
How to pass a two-dimensional array to a function in C language?
vs番茄助手的方便功能和便捷快捷键介绍
The difference between LDO and DC-DC
51 serial communication (on)
【深度学习】聊一聊什么是卷积神经网络,卷积是什么意思?
2022-08-08:给定一个数组arr,表示从早到晚,依次会出现的导弹的高度。 大炮打导弹的时候,如果一旦大炮定了某个高度去打,那么这个大炮每次打的高度都必须下降一点。 1) 如果只有一个大炮,返回
Deep Learning - Principles of Neural Networks 2
SiO2/KH550修饰四氧化三铁纳米磁性颗粒|PDA包裹四氧化三铁磁性纳米颗粒(科研级)
Can Jincang Database Set Transaction Automatic Commit?
51串口通信(上)
MOS管的选型
[MySQL]二、进程的关系、MySQL密码破解、建表和建库相关命令
金仓数据库能否设置事务自动提交
弄潮 Web3 欧易OKX全球「抢人」
#define