Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: problem and error in my code pass parameter Post Reply Post New Topic
Author Message
flodi
Newbie
Newbie
Avatar

Joined: 27 Feb 2012
Location: Saudi Arabia
Online Status: Offline
Posts: 1
Quote flodi Replybullet Topic: problem and error in my code pass parameter
    Posted: 27 Feb 2012 at 9:57pm
hi
am doing program in vb.net 2010 with sql serevr 2008 and i would like to pass a parameter to my crystal report to print a two related table and make an invoic print
here is my code

Private Sub CmdSearchNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSearchNo.Click
        Try
            Dim em1 As String = InputBox("Enter inv_no?")
            Dim conn As SqlConnection
            conn = New SqlClient.SqlConnection
            conn.ConnectionString = "Data Source=dell-dsl\sqlexpress;Initial Catalog=STOCK;Integrated Security=True"
            conn.Open()
            Dim cmm As SqlCommand
            cmm = New SqlClient.SqlCommand
            cmm.Connection = conn
            cmm.CommandText = "select * from INVHEADOUT where inv_no= '" & Trim(em1) & "' "
            cmm.CommandType = CommandType.Text
            Dim read As SqlClient.SqlDataReader
            read = cmm.ExecuteReader
            If Not read.Read Then
                MsgBox("inv_no not found")
                read.Close()
                conn.Close()
            Else
                Dim pram As New ParameterFields
                Dim para As SqlParameter
                para = New SqlParameter("@pinv_no", SqlDbType.SmallInt)
                para.Value = em1
                Dim par As New ParameterField
                par.ParameterFieldName.Equals("@pinv_no")
                par.CurrentValues.Add(para)
                pram.Add(par)
                CrystalReportViewer1.ParameterFieldInfo = pram
                CrystalReportViewer1.Visible = True
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

its under my print button and the error message is ( invalide object type ) in the line
par.CurrentValues.Add(para)

any suggestion or help?
thx
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.