Click here to Skip to main content
15,888,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all

I am getting error while inserting value to the database

Please check my below code and tell me what is the problem

Code
VB
Dim cm As New SqlCommand("insert into Transportation_Courier_AddressDiary(Name,Alias,ContactPerson,PerParcel,PaymentTerms,CompanyName,Groups,HouseAddress,Memo,GroupRef,Address,City,State,Pincode,Phone1,Phone2,Mobile,Fax,Email,Website,TIN,VATNo,ServiceTAX,IT) values (NULL,'" & txtAddressDiaryAlias.Text & "','" & txtContactPerson.Text & "',NULL,NULL,'" & txtcname.Text & "','" & cmbGrouping.Text & "','" & txthouseaddress.Text & "','" & txtmemo.Text & "',3,'" & txtAddress.Text & "','" & cmbCity.Text & "','" & cmbState.Text & "','" & txtPincode.Text & "','" & txtPhone1.Text & "','" & txtPhone2.Text & "','" & txtMobile.Text & "','" & txtFax.Text & "','" & txtEmail.Text & "','" & txtWebsite.Text & "','" & txtTIN.Text & "','" & txtVatNo.Text & "','" & txtservicetax.Text & "','" & txtIT.Text & "')", constr)



Error
Object reference not set to an instance of an object.
Posted

1 solution

constr - is that null? Where is that defined and initialized? If the error really oocurs in the line you showed us, that's the only candidate for a NullReferenceException. But does it really occur here?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900