Conn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=hr;Data Source=SERVER"
Adodc2.ConnectionString = Conn
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "select * from 部门信息"
Adodc2.Refresh
上面代码如果网络没连接或连接错误就会出错
怎么判断是什么错误并给出相应处理???
Adodc2.ConnectionString = Conn
Adodc2.CommandType = adCmdText
Adodc2.RecordSource = "select * from 部门信息"
Adodc2.Refresh
上面代码如果网络没连接或连接错误就会出错
怎么判断是什么错误并给出相应处理???
.open的时候已经出错了,根本不能判断.State了
on error goto err:
..
...
exit sub
err:
msgbox err.description
------------------
其实这个过程不用担心,会报错提示
..
adodc1.refresh <<<<<<<<<<<<<<<<可是在这里就会有出错提示
exit sub
err:
msgbox err.description
On Error GoTo err:
..
...
Exit Sub
err:
Select Case err.Number
Case 错误代码
·····
Case ···
···
·····
End Select