|
Option Explicit
Public ConnDB As New ADODB.Connection
Public DBRst As ADODB.Recordset
Public ConnStr As String
Public SQLRst As String
Public irow As Integer, icol As Integer
Public OraOpen As Boolean
Public Sub OpenErp() '连接数据库
Set ConnDB = New ADODB.Connection
Set DBRst = New ADODB.Recordset
OraOpen = False
ConnStr = "Provider=SQLOLEDB;Initial Catalog=****;User ID=sa;Password=****;Data Source=192.168.0.156\STL"
ConnDB.CursorLocation = adUseServer
ConnDB.Open ConnStr
OraOpen = True
DBRst.ActiveConnection = ConnDB
DBRst.CursorLocation = adUseServer
DBRst.LockType = adLockBatchOptimistic
Application.ScreenUpdating = False '关闭屏幕刷新
Exit Sub
ONEXIT:
MsgBox "无法联接数据库", 16, "操作中止"
End Sub
连接数据库的命令
Call OpenErp
Sql = "select * from FORECAST"
DBRst.Open Sql, ConnDB, adOpenKeyset, adLockOptimistic
执行查询的命令
Call OpenErp
Sql = "delect from FORECAST where CDATE= '" & rq & "'"
ConnDB.Execute Sql
ConnDB.Execute Sql提示这个错误,不知道错在哪,该如何修改
|
|