Thursday, March 8, 2012

Crystal Report (using stored procedures - parameter passing)

i have created a crystal report using a stored procedure. in the web form im passing a parameter thru a textbox. but that value is not passing properly.

Dim myCMD As New SqlCommand("select_all_infor", myConn)
myCMD.CommandType = CommandType.StoredProcedure
Dim parr As New SqlClient.SqlParameter("@.Pid", SqlDbType.Int)
parr.Direction = ParameterDirection.Input
parr.Value = TextBox1.Text
myCommand.Parameters.Add(parr)
myCommand.Parameters.Add("@.Pid", TextBox1.Text)

Dim myDA As New SqlDataAdapter
myDA.SelectCommand = myCMD

Dim myDS As New myDS
myDA.Fill(myDS)

Dim myRPT As New fromSP_REPORT

myRPT.SetDataSource(myDS)

CrystalReportViewer1.ReportSource = myRPT

this is what i've written. Im not sure about connecting to a dataset. Pls correct me.

it's giving this error:

Procedure 'select_all_infor' expects parameter '@.Pid', which was not supplied.try to use this.

crReportDocument.SetParameterValue(0,(object) "first parameter");
crReportDocument.SetParameterValue(1,(object) "second parameter");

No comments:

Post a Comment