Calling Stored Procedure while passing parameters from Access Module in VBA

前端 未结 2 483
孤街浪徒
孤街浪徒 2020-12-07 04:02

I am working in Access 2010 with a Microsoft SQL Server 2008 backend. I have a stored procedure that inserts new values(supplied by the parameters) into a table. The value

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 04:34

    Dim conn As ADODB.Connection 
    Dim cmd As ADODB.Command 
    
    Set conn = New ADODB.Connection 
    conn.ConnectionString = “your connection String here” 
    conn.Open 
    
    Set cmd = New ADODB.Command 
    cmd.ActiveConnection = conn 
    cmd.CommandType = adCmdStoredProc 
    cmd.CommandText = "upInsertToInstrumentInterfaceLog" 
    
    cmd.parameters.Append cmd.CreateParameter("@BatchID", adVarChar, adParamInput, 60, "value for BatchID")   
    cmd.parameters.Append cmd.CreateParameter("@InstrumentName", adVarChar, adParamInput, 60, "value for InstrumentName")   
    '...
    
    cmd.Execute 
    conn.Close 
    

提交回复
热议问题