在数据库表中插入值时出错 [英] Getting error while inserting the value in database table

查看:88
本文介绍了在数据库表中插入值时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我在向数据库插入价值时收到错误



请检查我的下面的代码告诉我是什么问题



代码

<前lang =vb> Dim cm As SqlCommand( 插入Transportation_Courier_AddressDiary(名称,别名,ContactPerson,PerParcel,PaymentTerms,CompanyName,Groups,HouseAddress,Memo,GroupRef,Address,City,State,Pincode,Phone1,Phone2 ,移动,传真,电子邮件,网站,TIN,VATNo,ServiceTAX,IT)值(NULL,'& txtAddressDiaryAlias.Text& < span class =code-string>','& 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)







错误

对象引用未设置为对象的实例。

解决方案

constr - 是空的吗?定义和初始化的位置在哪里?如果错误真的在你向我们展示的行中出现,那就是Nul​​lReferenceException的唯一候选者。但这真的发生在这里吗?


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

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.

解决方案

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?


这篇关于在数据库表中插入值时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆