i haven't used ado fro a while and i've forgotten some of it. below is my ado code and the storedproc. the insert works fine. but i can't get/display the return value.
any help would be appreciated
Code:Dim cmd As New ADODB.Command Dim rs As New ADODB.Recordset Dim con As New ADODB.Connection Dim unidParam As ADODB.Parameter Dim changeReasonParam As ADODB.Parameter Dim changeNotesParam As ADODB.Parameter Dim userNameParam As ADODB.Parameter Dim changedToParam As ADODB.Parameter Dim returnValue As ADODB.Parameter Dim conString As String cmd.CommandType = 4 cmd.CommandText = "sp_Save_Update" 'set params Set unidParam = cmd.CreateParameter("unid", adChar, adParamInput, 32) Set changeReasonParam = cmd.CreateParameter("changereason", adInteger, adParamInput, 4) Set changeNotesParam = cmd.CreateParameter("changenotes", adVarChar, adParamInput, 2048) Set changedToParam = cmd.CreateParameter("changedto", adInteger, adParamInput, 4) Set userNameParam = cmd.CreateParameter("username", adVarChar, adParamInput, 30) Set returnValue = cmd.CreateParameter("returnvalue", adInteger, adParamReturnValue, 4) 'append params to command cmd.Parameters.Append unidParam cmd.Parameters.Append changeReasonParam cmd.Parameters.Append changeNotesParam cmd.Parameters.Append changedToParam cmd.Parameters.Append userNameParam cmd.Parameters.Append returnValue unidParam.Value = UNID changeReasonParam.Value = ChangeReason changeNotesParam.Value = Notes changedToParam.Value = ChangedTo userNameParam.Value = Username '(RS) tidy this up. 'in clsdb create a function called getcmd that returns a comand 'object with its active connection set, then will just need to set 'all the otehr properties ' Create recordset by executing the command. Set con = db.getConnectionObject conString = db.getConnectionString con.Open conString Set cmd.ActiveConnection = con Set rs = cmd.ExecuteCode:@unid char(32), @changereason int, @changenotes varchar(2048), @changedto int, @username varchar(30), @returnvalue int output AS insert into tbl_update(unid, username, change_reason, change_to, change_notes, date_created) values (@unid, @username, @changereason, @changedto, @changenotes, getdate()) set @returnvalue = @@identity




Reply With Quote