Naresh_SuryaOccasional ContributorJoined 5 years ago11 Posts1 LikeLikes received1 SolutionView All Badges
ContributionsMost RecentMost LikesSolutionsRe: How to pass Date as in parameter for stored proc Sure Wamboo . // Adding a return parameter SProc.Parameters.AddParameter() SProc.Parameters.Items(0).name = "RETURN_VALUE" SProc.Parameters.Items(0).DataType = adInteger SProc.Parameters.Items(0).Direction = adParamReturnValue SProc.Parameters.Items(0).Value = null //Adding an in parameter SProc.Parameters.AddParameter() SProc.Parameters.Items(1).name = "@timeOfBuild" SProc.Parameters.Items(1).DataType = adDate SProc.Parameters.Items(1).Value = aqConvert.strtoDate("2020-05-19") SProc.CommandTimeout = 75; SProc.ExecProc(); Re: How to pass Date as in parameter for stored proc Wamboo , Thank you for your time. But I have got a way to fix this issue with my initial code ADO.createADOStoredroc() method. I have passed Date string by converting it to date format using aqConvert which fixed. Re: How to pass Date as in parameter for stored proc It's Empty Object Re: How to pass Date as in parameter for stored proc Wamboo , Thank you for taking time to help here. Though I accepted your solution. I am not able to validate the response from Stored proc and also doesn't know if it's executed or not. var sql = "EXEC <stored procname> @date = N'"+Date+"'" var conn = ADO.CreateCommand(); conn.ActiveConnection = "Provider=SQLOLEDB;Initial Catalog=<>;User ID=<>;Password=<>;Data Source= \"*\" "; conn.CommandType = adCmdText; conn.CommandText = sql; conn.CommandTimeout = 65000; try { var RecSet = conn.Execute(); while (!RecSet.EOF) { Log.Message(RecSet.Fields.Item("Return Value").Value); RecSet.MoveNext(); }; // Log.Message(exe); } catch(exception) { Log.Message(exception); Log.Message("FAIL"); } Exception at while block saying unable to perform operation on closed object. If I increase the timeout to 70000 it's giving query timeout exception. Can you please tell me what I am missing here Re: How to pass Date as in parameter for stored proc Thank you, I have tried passing EXEC command as sql and looks like it ran didn't print FAIL message. But I tried to print exe also which was empty. Any way that we can print response from stored procedure? Re: How to pass Date as in parameter for stored proc I've seen we can execute stored proc using Query and tried executing SQL query EXEC <stored proc name> @date=N'date'; It returned query timedout wrror as my stored proc takes more than 30 secs (close to one minute to get executed). Is there any way to mention querytimeout as we do commandtimeout in stored proc? Re: How to pass Date as in parameter for stored proc Sorry, I am new to dealing with stored procs. I assigned stored proc path to sql. ActiveConnection = Connection String(includes catalog, username/password) I didn't understand what to place at adCmdText. Re: How to pass Date as in parameter for stored proc Microsoft SQL Server Re: How to pass Date as in parameter for stored proc Wamboo , Thanks for your reply. Yes, I am trying to execute a Stored proc which is available in DB. I checked the parameter DataType in DB and is "datetime" As mentioned in below screenshot I tried those two TestComplete constants but I was getting the errors mentioned in my previous comment. Am I missing anything here? Re: How to pass Date as in parameter for stored proc Hi Thanks for that link. I have tried two TestComplete ADO constants for Date/DateTime mentioned but i am running into below issues Tried adDate as Datatype but got into "application uses a value of the wrong type for the current operation" issue. Tried adDBTimeStamp but got into "arguments are of the wrong type, are out of acceptable range, or are in conflict with one another" Can you confirm if it's because I am passing date in String format? If so, how can we pass the same?