我有这个大的SQL命令,通常返回20 000 - 100 000行数据.但是只要我调用executeMyQuery函数,程序就会挂起几秒钟,具体取决于返回的大小.
我只返回一列.
如何在运行此命令时显示进度条?
也许在线程或其他东西(我没有线程经验)
这是我的代码(参数从3个不同的combobox.selectedItem发送):
Public Function executeMyQuery(dbname As String, colname As String, tblname As String)
Try
ListBox1.Items.Clear()
If Not String.IsNullOrWhiteSpace(connString) Then
Using cn As SqlConnection = New SqlConnection(connString)
cn.Open()
Using cmd As SqlCommand = New SqlCommand()
cmd.Connection = cn
Dim qry As String
qry = String.Format("select distinct [{0}] from {1}.dbo.{2} where [{0}] is not null", colname, dbname, tblname)
cmd.CommandText = qry
cmd.CommandTimeout = 0
Dim count As Integer
Using myReader As SqlDataReader = cmd.ExecuteReader()
While …Run Code Online (Sandbox Code Playgroud) 我逐行循环遍历文本文件和 这个有趣的角色弹出太多,当我导入到MS SQL时,该符号会导致大量有趣的字符.
< - 这就是VB在字符串中看到它的方式.我在使用断点运行代码时将其复制出字符串.
只要在文本文件中找到某些特殊字符,该字符就会以字符串形式弹出.