View Single Post
  #1 (permalink)  
Old 01-13-2009, 4:45 PM
flodi flodi is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Jan 2008
Posts: 14
Reputation: 29
flodi is on a distinguished programming path ahead
Default error in send parameter to crystal report

hi
i make a program with vb.net2005 and database sql express 2005
i would like to press a print buuton to send a parameter in an inputbox to put value in it
here is my code:
Code:
dim mm1 as string
mm1=inputbox("enter number")
sqlconection1.open
dim cm as sqlclient.sqlcommand
cm=new sqlclient.sqlcommand
cm.connection=sqlconnection1
cm.commandtext="select * from table1 where id_no =' " & trim ( mm1 ) & " ' "
cm.commandtype=commandtype.text
dim read as sqlclient.sqldatareader
read=cm.executereader
if not read.Read then
msgbox("wrong number")
read.close
sqlconnection1.close
else
dim param as new parameterfields
dim pr as sqlparameter
pr=new sqlparameter("@pid_no",sqldbtype.nvarchar)
pr.value=mm1
dim pr1 as parameterfield
pr1.parameterfieldname="@pid_no"
pr1.currentvalue.add(pr)
param.add(pr1)
crystalreportviewer1.parameterfieldinfo=param
crystalreportviewer.visibale=true
sqlconnection1.close
afte i run the inputbox show up
i enter the value and press ok
an error show said:
Object Reference not set to an instance of an Object
in that line:
Code:
pr1.parameterfieldname="@pid_no"
why this error accured?plz help me
and thx
Reply With Quote