2

我有一个带有参数但不返回任何内容的存储过程。如何从 MS Access 中调用它?

编辑 - 在 Remou 的帮助下,我已经开始工作了:

Set cnn = New adodb.Connection
cnn.ConnectionString = 
   "driver=SQL Server;server=SERVER\SERVER;database=a_db;Trusted_Connection=Yes"

cnn.Open cnn.ConnectionString

Set cmd = New adodb.Command
cmd.ActiveConnection = cnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "stprMoveDataSet"

Set param = cmd.CreateParameter
                ("DataSetID", adInteger, adParamInput, 6, stDataSet)
cmd.Parameters.Append param
Set param = cmd.CreateParameter
                ("Destination", adChar, adParamInput, 2, stDestination)
cmd.Parameters.Append param

rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.Open cmd
4

1 回答 1

4

这是一个可能会有所帮助的大纲。稍后我可能会回来提供更多详细信息。它并不特定于您的情况,但它可能会让您继续前进:)

Public dbconn As ADODb.Connection
Dim cmd As New ADODb.command
Dim rs As New ADODb.Recordset
Dim param As New ADODb.Parameter

Set dbconn = New ADODb.Connection
dbconn.ConnectionString = GetServerCon

dbconn.Open dbconn.ConnectionString

Set cmd = New ADODb.command
cmd.ActiveConnection = dbconn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "insert_user"

Set param = cmd.CreateParameter(_
   "username", adVarChar, adParamInput, 50, Environ("UserDomain") & "dddddddd\" _
   & Environ("Username"))
cmd.Parameters.Append param

rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.Open cmd
于 2012-09-13T12:29:17.530 回答