以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  登录按钮代码 运行之后 项目要等待好久才能进入主窗口 麻烦老师帮忙看看有没有办法再优化一下代码 减少等待响应时间呢?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=169861)

--  作者:cnsjroom
--  发布时间:2021/7/4 8:54:00
--  登录按钮代码 运行之后 项目要等待好久才能进入主窗口 麻烦老师帮忙看看有没有办法再优化一下代码 减少等待响应时间呢?
登录按钮代码  运行之后 项目要等待好久才能进入主窗口  麻烦老师帮忙看看有没有办法再优化一下代码 减少等待响应时间呢?

图片点击可在新窗口打开查看此主题相关图片如下:捕获.png
图片点击可在新窗口打开查看
代码如下:
Dim cmd As New SQ LCommand
cmd.Connect ion Name = _DATA
If e.Form.Controls("ComboBox1").Value = ""  Then
    Messagebox.show("请选择单位或者输入单位!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
Else  If e.Form.Controls("UserName").Value = ""  Then
    Messagebox.show("请选择用户或者输入用户名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
Else If e.Form.Controls("PassWord").Value = ""  Then
    Messagebox.show("请输入密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
Else
    cmd.CommandText = "Se lect * From {systemuser} Where [username] = \'" & e.Form.Controls("UserName").Value & "\'"
    Dim dt As DataTable = cmd.ExecuteReader
    If dt.DataRows.Count = 0 Then
        Messagebox.show("此用户不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Return
    End If
    Dim dr As DataRow = dt.DataRows(0)
    If e.Form.Controls("PassWord").Value = dr("Password") And e.Form.Controls("ComboBox1").Value = dr("所在单位") Then
        _UserName = e.Form.Controls("UserName").Value
        _UserGroup = dr("所在单位")
        _DATA=e.Form.Controls("ComboBox2").Value
        vars("单位")=dr("所在单位")
        e.Form.Close
        Forms("主窗口").show
    Else
        Messagebox.show("所在单位或用户名或密码输入错误!,请核查!","温馨提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If
[此贴子已经被作者于2021/7/4 8:55:20编辑过]

--  作者:有点蓝
--  发布时间:2021/7/4 20:36:00
--  
自己计算一下每一段代码的耗时:http://www.foxtable.com/webhelp/topics/0287.htm

去掉这句【Forms("主窗口").show】看慢不慢

--  作者:cnsjroom
--  发布时间:2021/7/5 9:14:00
--  回复:(有点蓝)自己计算一下每一段代码的耗时:http...
去掉这句【Forms("主窗口").show】之后不慢了 
但是打开的窗体就没有主窗口这个窗体内容了  有没有解决慢的情况  又能够打开主窗口的办法呢?
谢谢老师!

--  作者:有点蓝
--  发布时间:2021/7/5 9:35:00
--  
说明是"主窗口"打开慢,和登录窗口没有关系
检查"主窗口"打开都执行了什么代码,调试看是哪一段代码慢