Sql server custom code issue
I created a report in SQL Server 2005 using SQL Server 2005. I added a custom code to the report as:
function getpiececount_parent(byval qb_prodcode as string,byval s_date as string,byval e_date as string)
dim conn as new System.Data.SqlClient.SqlConnection
conn.ConnectionString= "Data Source=xxxx;Initial Catalog=xxxx;User Id=xxxx;Password=xxxxx "
conn.open()
dim sql as string
sql="select query using parameters"
dim cmd as new System.Data.SqlClient.SqlCommand
cmd.connection=conn
cmd.commandtext=sql
cmd.Parameters.AddWithValue("@stDate",s_date)
cmd.Parameters.AddWithValue("@edDate",e_date)
cmd.Parameters.AddWithValue("@qbprodcode",qb_prodc ode)
dim retval =cmd.ExecuteScalar()
if retval is system.dbnull.value then
retval=0
end if
cmd.dispose()
conn.close()
return retval
end function
For the above function I added reference to the System.Data . The report works as desired when I execute in the VS 2005 IDE but when I deploy the report on the reporting server and execute it from there the function doesnât execute and returns me #Error.
Can any one provide some insight into it to as to how i can resolve this issue.
|