Private Sub Form_Load()
Adodc1.ConnectionString = library_general_2.about_db_register.connection_string ‘注册数据库
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "select top 1 ba0201 from ba02 with (nolock) "
Adodc1.Refresh
End subPrivate Sub Command_ok_Click()
Dim st05_adodb_recordset As New ADODB.Recordset
st05_adodb_recordset.Open "select * from ba03 with (nolock) where ba0302='" & db_text_box_general(1).Text & "' order by ba0302 ", Adodc1.Recordset.ActiveConnection, , adLockOptimistic
If st05_adodb_recordset.RecordCount > 0 Then
MsgBox "相现名称规格的物料件号已存在﹐无需再新增件号"
db_text_box_general(1).SetFocus
Exit Sub
End If
end sub-----------------------------------------------------------------------
问题:Command_ok_Click以前不会出现问题的,但现在 不定时 出现错误提示“[DBNETLIB] Connection Write (send())”。现在解决方法非要重新注册一次
即:Private Sub Command_ok_Click()
Adodc1.ConnectionString = library_general_2.about_db_register.connection_string ‘注册数据库
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "select top 1 ba0201 from ba02 with (nolock) "
Adodc1.RefreshDim st05_adodb_recordset As New ADODB.Recordset
st05_adodb_recordset.Open "select * from ba03 with (nolock) where ba0302='" & db_text_box_general(1).Text & "' order by ba0302 ", Adodc1.Recordset.ActiveConnection, , adLockOptimistic
If st05_adodb_recordset.RecordCount > 0 Then
MsgBox "相现名称规格的物料件号已存在﹐无需再新增件号"
db_text_box_general(1).SetFocus
Exit Sub
End If
end sub注:数据库是SQL