How to pass Date as in parameter for stored proc
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to pass Date as in parameter for stored proc
I tried below code
// 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 = adDBDateTime // what should we pass here I tried adDBTime and adDBTimeStamp also
SProc.Parameters.Items(1).Value = "2020-05-19"
SProc.CommandTimeout = 120;
SProc.ExecProc();
Can someone please help me here? I am getting adDBDateTime is not defined. Thanks in advance
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
conn.CommandType = adCmdText;
conn.CommandText = sql;
conn.CommandTimeout = 6000;
adCmdText - You don't have to specify this, this parameter is the type of function to be executed.
CommandTimeout - This is the default time to run the script. Increase it as you wish.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
what Do you have in "var RecSet = conn.Execute();" while debugging?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's Empty Object
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great to hear that.
Can you share code with the community ?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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();

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »