Simply use ADO Command object, which passes the parameters, to execute
whatever SP you choose. Here is pseudo-code:
Private Sub CommandButton1_Click()
Dim cmd As ADO.Command
Dim pmt As ADO.Parameter
Set cmd=New ADO.Command
Set cmd.ActiveConnection=CurrentProject.Connection
cmd.CommandType=adCmdStoredProc
cmd.CommandText="MySPName"
''Create Paramters required by the SP
Set pmt=cmd.CreateParameter(....)
cmd.Parameters.Append pmt
''More parameters here
''Execute the SP
cmd.Execute
End
As for performing double insertion i a SP, it should be farly easy, like:
Create Procedure "MySPForInsertion"
(
@Para1 varchar(50),
@Para2 int,
...
)
AS
DECLARE @ID int
/*Assume Table1 has a Identity column*/
INSERT INTO Table1 (Col1,Col2,...)Values (@Para1,@Para2,...)
SET @ID=SCOPE_IDENTITY()
/*Insert to Table2
INSERT INTO Table2 (ParentIDCol,Col1,Col2,...) VALUES
(@ID,'Value1','Value2',...)
RETURN
You can also return the auto-generated ID back to ADO.Command object by
using output parameter, so the Command object will execute the SP and get
the new ID back in one round trip to the sql server.
"Steven" <Steven@discussions.microsoft.com> wrote in message
news:6337C748-16FF-49F2-A037-D6A982E2597C@microsoft.com...
|