flodi
Member
- Joined
- Jan 23, 2008
- Messages
- 15
- Programming Experience
- Beginner
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:
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:
why this error accured?plz help me
and thx
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:
VB.NET:
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
i enter the value and press ok
an error show said:
Object Reference not set to an instance of an Object
in that line:
VB.NET:
pr1.parameterfieldname="@pid_no"
and thx