CerMataJary
New Member
Using ADO versus stored procedure for Create and UpdateI am using Classic ASP, SQL server 2008 R2. I have been using ADO like this to do create and updates:\[code\]sSQL = "select <column list> from <table>"set rsMyTable = Server.CreateObject ("ADODB.Recordset")rsMyTable.cursorType = 2 sMyTable.LockType = 3 rsMyTable.open sqlstr, objMyConnection rsMyTable.addnewrsMyTable("Mycol1") = myValue1rsMyTable("Mycol2") = myValue2rsMyTable.updatersMyTable.closeset rsMyTable = nothing\[/code\]I have several tables that need to be updated and each update updates different sets of columns. Is it a bad practice to use ADO like this? Instead of using ADO, should I create stored procedures for each update and pass parameters to the stored procedure using ADO like this:\[code\]sqlstr = "myUpdateProcedure"set objCmd = Server.CreateObject("ADODB.Command")set objParam = Server.CreateObject("ADODB.Parameter")set objCmd.ActiveConnection = objConnectionobjCmd.commandText = sqlstrobjCmd.CommandType = 4 ''stored proc.set objParam = objCmd.CreateParameter("param1", 19, 1, , value1)objCmd.Parameters.Append objParamset objParam = objCmd.CreateParameter("param2", 200, 1, <maxlength>, value2)objCmd.Parameters.Append objParam....set rsTemp = Server.CreateObject("ADODB.Recordset")rsTemp.CursorLocation = adUseClientrsTemp.CursorType = adOpenKeysetset rsTemp = objCmd.Execute()....''cleanup.set objParam = Nothingset objCmd = NothingSet rsTemp = Nothing\[/code\]I appreciate any advice.
Thanks.
Thanks.