Public Function ConnectDB() As Boolean
On Error GoTo ErrorHandle
Dim e As ADODB.Error
ConnectDB = True
cnnDatabase.Errors.Clear
cnnDatabase.CommandTimeout = 60
cnnDatabase.ConnectionTimeout = 60
cnnDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\yanruyue.mdb"
cnnDatabase.Open
Exit Function
ErrorHandle:
If cnnDatabase.Errors.Count < 1 Then
MsgBox Err.Description, vbOKOnly + vbExclamation
Else
For Each e In cnnDatabase.Errors
MsgBox e.Description
Next e
End If
ConnectDB = False
Set cnnDatabase = Nothing
Exit Function
End Function数据库是这样连接的
货物入库
Private Function SuppInfo_Add() As Boolean
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim intRst As Integer
SuppInfo_Add = False
If CheckFaceIsOk = False Then
Exit Function
End If
strSQL = "SELECT * FROM 入库 where 编号 = " & Me.txt5.Text & ""
rst.Open strSQL, cnnDatabase, adOpenStatic, adLockOptimistic
rst.AddNew
rst.Fields("名称").Value = Me.txt1.Text
rst.Fields("入库时间").Value = Me.DT_RegeditDate.Value
rst.Fields("仓管员").Value = Me.txt2.Text
rst.Fields("入库数量").Value = Me.txt3.Text
rst.Fields("编号").Value = Me.txt5.Text
rst.Fields("入库人").Value = Me.txt6.Text
rst.Fields("线体").Value = Me.txt8.Text
If Me.txt4.Text = "" Then
rst.Fields("备注").Value = "无"
Else
rst.Fields("备注").Value = Me.txt4.Text
End If
On Error Resume Next
rst.Update
MsgBox "添加新的物品信息成功!"
Set rst = Nothing
kucun_Add
Initial_Add
SuppInfo_Add = False
Exit Function但是物品编码输入超过11位就报错!实时错误 '-2147217904 (80040e10)'
[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1
On Error GoTo ErrorHandle
Dim e As ADODB.Error
ConnectDB = True
cnnDatabase.Errors.Clear
cnnDatabase.CommandTimeout = 60
cnnDatabase.ConnectionTimeout = 60
cnnDatabase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\yanruyue.mdb"
cnnDatabase.Open
Exit Function
ErrorHandle:
If cnnDatabase.Errors.Count < 1 Then
MsgBox Err.Description, vbOKOnly + vbExclamation
Else
For Each e In cnnDatabase.Errors
MsgBox e.Description
Next e
End If
ConnectDB = False
Set cnnDatabase = Nothing
Exit Function
End Function数据库是这样连接的
货物入库
Private Function SuppInfo_Add() As Boolean
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim intRst As Integer
SuppInfo_Add = False
If CheckFaceIsOk = False Then
Exit Function
End If
strSQL = "SELECT * FROM 入库 where 编号 = " & Me.txt5.Text & ""
rst.Open strSQL, cnnDatabase, adOpenStatic, adLockOptimistic
rst.AddNew
rst.Fields("名称").Value = Me.txt1.Text
rst.Fields("入库时间").Value = Me.DT_RegeditDate.Value
rst.Fields("仓管员").Value = Me.txt2.Text
rst.Fields("入库数量").Value = Me.txt3.Text
rst.Fields("编号").Value = Me.txt5.Text
rst.Fields("入库人").Value = Me.txt6.Text
rst.Fields("线体").Value = Me.txt8.Text
If Me.txt4.Text = "" Then
rst.Fields("备注").Value = "无"
Else
rst.Fields("备注").Value = Me.txt4.Text
End If
On Error Resume Next
rst.Update
MsgBox "添加新的物品信息成功!"
Set rst = Nothing
kucun_Add
Initial_Add
SuppInfo_Add = False
Exit Function但是物品编码输入超过11位就报错!实时错误 '-2147217904 (80040e10)'
[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1
strSQL = "SELECT * FROM 入库 where 编号 = '" & Me.txt5.Text & "'"
另外,检查编号的长度是多少
strSQL = "SELECT * FROM 入库 where 编号 = '" & Me.txt5.Text & "'"