sql server - Calling Stored Procedure in Access VBA only with the correct order of parameters, why? -
i have little problem executing stored procedure access. using "microsoft activex data objects 2.8 library" ms sql server 2008.
for calling stored procedures this:
set cmd = init_adodbcommand("sp_002_test_tabellenparameter") cmd.parameters("@str_test") = "test" cmd.parameters("@str_test2") = "test" cmd.execute
i ok that, there issues if using nvarchar(max) variable in stored procedure using code, works fine too:
set cmd = init_adodbcommand("sp_002_test_tabellenparameter") cmd.parameters.append cmd.createparameter("@str_test", adlongvarwchar, adparaminput, -1, "test") cmd.parameters.append cmd.createparameter("@str_test2", adlongvarwchar, adparaminput, -1, "test") cmd.execute
it works too, if parameters in correct order, added in stored procedure on server. behaviour doesn't happen first option mentioned @ beginning! option can address parameter directly.
the code of sp on server starts that:
alter procedure [dbo].[sp_002_test_tabellenparameter] -- add parameters stored procedure here @str_test nvarchar(max) = null, @str_test2 nvarchar(max) = null
i have lot of stored procedures more 30 parameters , of these parameters aren't needed , don't won't "give shit" correct order... :d
it looks doesn't matter name parameter using in access.
where fault?
thank you! :)
attachment code initialize:
dim cmd_temp adodb.command dim adoconn_connection_tmp adodb.connection set adoconn_connection_tmp = new adodb.connection set adoconn_connection_tmp = adoconnobj set cmd_temp = new adodb.command cmd_temp.commandtype = adcmdstoredproc cmd_temp.commandtext = str_prozedurname cmd_temp.activeconnection = adoconn_connection_tmp set init_adodbcommand = cmd_temp end function
you need add line
cmd_temp.namedparameters = true
to command object initializer.
Comments
Post a Comment