Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Non-Standard Values to a Stored Procedure

Status
Not open for further replies.

dellyjm

Programmer
Apr 13, 2000
168
JM
Hi everyone i'm passing a parameter to a SQL Server Database (6.5) but the problem is that the value that has to be passed needs to be in this format '2000/01/01'. Check out the code below, it returns an error, it will pass 2000/01/01 with ease but not in the format I require.<br><br>ParDate = &quot;'&quot; & &quot;2000/01/22&quot; & &quot;'&quot;<br><br>With Comm<br>&nbsp;&nbsp;&nbsp;.CommandText = &quot;sp_run_invoices&quot;<br>&nbsp;&nbsp;&nbsp;.CommandType = adCmdStoredProc<br>&nbsp;&nbsp;&nbsp;.ActiveConnection = Conn<br>&nbsp;&nbsp;&nbsp;.Parameters.Refresh<br>&nbsp;&nbsp;&nbsp;.Parameters(&quot;@pub_date&quot;).Value = ParDate<br>&nbsp;&nbsp;&nbsp;.Parameters(&quot;@pub_date&quot;).Direction = adParamInput<br>&nbsp;&nbsp;&nbsp;.Execute<br>End With<br><br>Any solutions.<br>&nbsp;
 
I didn't understand clearly your question...<br><br>1) do you want to pass STRING (&quot;'2000/01/22'&quot;)?<br>&nbsp;&nbsp;I found no problem. It's very strange string (with<br>&nbsp;&nbsp;apostrophe), but it was passed (to string parameter).<br><br>2) do you want to pass DATE?<br>&nbsp;&nbsp;Hm... Why do you add apostrophes to string?<br>&nbsp;&nbsp;If you'll delete them, date will be passed to<br>&nbsp;&nbsp;date parameter. Basic converts this string to date.<br><br>I hope it'll help you.
 
You haven't mentioned what error is coming up after execution of the code, but what I understand through your code. You are passing wrong date parameter. Pass date simply like this<br>ParDate = &quot;'&quot; & 2000/01/22 & &quot;'&quot;<br>SQL will convert into date type if you define date type parameter in your SP.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top