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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing string data to command object

Status
Not open for further replies.

jheaton

IS-IT--Management
Jun 6, 2003
23
US
I have a page that passes a variables as a string to a second page. The second page uses the following code to execute a stored procedure which parses the string data, and forms a select statement out of it.

<%@LANGUAGE=&quot;VBSCRIPT&quot; CODEPAGE=&quot;1252&quot;%>
<!--#include file=&quot;Connections/svrsql.asp&quot; -->
<%

Dim Command1__BuildingID
Command1__BuildingID = &quot;&quot;
if(Request.QueryString(&quot;BuildingID&quot;) <> &quot;&quot;) then Command1__BuildingID = Request.QueryString(&quot;BuildingID&quot;)

Dim Command1__StartDate
Command1__StartDate = &quot;200302&quot;
if(Request.QueryString(&quot;StartDate&quot;) <> &quot;&quot;) then Command1__StartDate = Request.QueryString(&quot;StartDate&quot;)

Dim Command1__EndDate
Command1__EndDate = &quot;200306&quot;
if(Request.QueryString(&quot;EndDate&quot;) <> &quot;&quot;) then Command1__EndDate = Request.QueryString(&quot;EndDate&quot;)

%>
<%

set Command1 = Server.CreateObject(&quot;ADODB.Command&quot;)
Command1.ActiveConnection = MM_svrsql_STRING
Command1.CommandText = &quot;MRI_USER.sp_viiGetCashFlowAccounts2&quot;
Command1.Parameters.Append Command1.CreateParameter(&quot;@RETURN_VALUE&quot;, 3, 4)
Command1.Parameters.Append Command1.CreateParameter(&quot;@BuildingID&quot;, 200, 1,100,Command1__BuildingID)
Command1.Parameters.Append Command1.CreateParameter(&quot;@StartDate&quot;, 129, 1,6,Command1__StartDate)
Command1.Parameters.Append Command1.CreateParameter(&quot;@EndDate&quot;, 129, 1,6,Command1__EndDate)
Command1.CommandType = 4
Command1.CommandTimeout = 0
Command1.Prepared = true
set rsData = Command1.Execute
rsData_numRows = 0

%>


I know the stored procedure is working correctly because when I run it in SQL query analyzer, it works perfectly. Also, my second page works correctly when I only pass 1 item in the string. It's only when I try to pass more than 1 item via the string (i.e. 'Building1,Building2'), that I get an error. The error I am recieving is:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E57)
[Microsoft][ODBC SQL Server Driver][SQL Server]String or binary data would be truncated.
/custommri/CashFlowsCalcBeta.asp, line 30

Note: Line 30 is the line with set rsData = Command1.Execute on it. My question is, why is the data being truncated? ...and how can I keep it from being truncated?

Thanks,
Josh
 
sure. It's an internal web site, and thus not viewable from the Internet, but I'm guessing you want the URL to see what parameters are being passed. It was my understanding that multi-select list boxes (which is what BuildingID is), when read by the recieving page, are percieved as CSV strings. Although, looking at this, I'm not so sure. Is this correct?

 
oops! looking over my code again, i did find a mistake.

My start / end date variables should be this:

Dim Command1__StartDate
Command1__StartDate = &quot;200302&quot;
if((Request.QueryString(&quot;StartYear&quot;) & Request.QueryString(&quot;StartMon&quot;)) <> &quot;&quot;) then Command1__StartDate = (Request.QueryString(&quot;StartYear&quot;) & Request.QueryString(&quot;StartMon&quot;))

Dim Command1__EndDate
Command1__EndDate = &quot;200306&quot;
if((Request.QueryString(&quot;EndYear&quot;) & Request.QueryString(&quot;EndMon&quot;)) <> &quot;&quot;) then Command1__EndDate = (Request.QueryString(&quot;EndYear&quot;) & Request.QueryString(&quot;EndMon&quot;))

However, changing these, seems to have no effect on the out come. I am still getting the same error message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top