server sql vb连接超时

server sql vb连接超时,第1张

一般在连接字符串中设置Connect Timeout=5,如果超过5秒,就会出现错误提示。

dim constr as string

constr="server=;database=数据库名;UID=XXXXXXX;PWD=XXXXXX;Connect Timeout=5"

代码不一样

text4text="17216239254" 时

chr(34) & Text4Text & chr(34)

结果是

"17216239254"

并没有 >

两个命令按钮,一个text,一个timer代码:Dim

t

As

Integer

Private

Sub

Command1_Click()

t

=

Text1Text

MsgBox

"系统将在"

&

t

&

"分钟后自动断开网络连接"

Timer1Enabled

=

True

MeHide

End

SubPrivate

Sub

Command2_Click()

MeHide

End

SubPrivate

Sub

Form_Load()

AppTaskVisible

=

False

Timer1Enabled

=

False

Timer1Interval

=

60000

Dim

ret

As

Long

preWinProc

=

GetWindowLong(Mehwnd,

GWL_WNDPROC)

ret

=

SetWindowLong(Mehwnd,

GWL_WNDPROC,

AddressOf

Wndproc)

idHotKey

=

1

Modifiers

=

MOD_CONTROL

uVirtKey

=

vbKeyA

ret

=

RegisterHotKey(Mehwnd,

idHotKey,

Modifiers,

uVirtKey)

End

Sub

Private

Sub

Timer1_Timer()

t

=

t

-

1

If

t

<=

0

Then

Shell

"Rasdial

/DISCONNECT"

End

If

End

Sub

然后再把以下代码写到模块中:Declare

Function

SetWindowLong

Lib

"User32"

Alias

"SetWindowLongA"

(ByVal

hwnd

As

Long,

ByVal

nIndex

As

Long,

ByVal

dwNewLong

As

Long)

As

Long

Declare

Function

GetWindowLong

Lib

"User32"

Alias

"GetWindowLongA"

(ByVal

hwnd

As

Long,

ByVal

nIndex

As

Long)

As

Long

Declare

Function

CallWindowProc

Lib

"User32"

Alias

"CallWindowProcA"

(ByVal

lpPrevWndFunc

As

Long,

ByVal

hwnd

As

Long,

ByVal

Msg

As

Long,

ByVal

wParam

As

Long,

ByVal

lParam

As

Long)

As

Long

Declare

Function

RegisterHotKey

Lib

"User32"

(ByVal

hwnd

As

Long,

ByVal

id

As

Long,

ByVal

fsModifiers

As

Long,

ByVal

vk

As

Long)

As

Long

Declare

Function

UnregisterHotKey

Lib

"User32"

(ByVal

hwnd

As

Long,

ByVal

id

As

Long)

As

LongPublic

Const

WM_HOTKEY

=

&H312

Public

Const

MOD_ALT

=

&H1

Public

Const

MOD_CONTROL

=

&H2

Public

Const

MOD_SHIFT

=

&H4

Public

Const

GWL_WNDPROC

=

(-4)Public

preWinProc

As

Long

Public

Modifiers

As

Long,

uVirtKey

As

Long,

idHotKey

As

LongPrivate

Type

taLong

ll

As

Long

End

TypePrivate

Type

t2Int

lWord

As

Integer

hWord

As

Integer

End

TypePublic

Function

Wndproc(ByVal

hwnd

As

Long,

ByVal

Msg

As

Long,

ByVal

wParam

As

Long,

ByVal

lParam

As

Long)

As

Long

If

Msg

=

WM_HOTKEY

Then

If

wParam

=

idHotKey

Then

Dim

lp

As

taLong,

i2

As

t2Int

lpll

=

lParam

LSet

i2

=

lp

If

(i2lWord

=

Modifiers)

And

i2hWord

=

uVirtKey

Then

Form1Show

End

If

End

If

End

If

Wndproc

=

CallWindowProc(preWinProc,

hwnd,

Msg,

wParam,

lParam)

End

Function

OK,完工了在这个软件的text1中输入你想要断开网络的时间,然后按下command1,窗体就会自动隐藏,按下“Ctrl

+

A”可以再次d出窗体(command2只是怕不小心按下Ctrl

+

A后无法再次隐藏窗体而设计的,按下它就可以再次隐藏窗体)断开网络连接后,如果没有关掉此软件,再次连接网咯时,系统会在1分钟内再次断开网络,这样别人就对你的电脑没辙了,哈哈。望采纳

以上就是关于server sql vb连接超时全部的内容,包括:server sql vb连接超时、VB检测网络连接停止响应、怎样用VB断开网络连接等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10111202.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存