本文介绍了我有以下错误请帮我解决它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有以下代码









i have following code




string SqlQuery = "Update " + frmmain.CityName + " set  assignedtouserid='" + frmmain.UserName + "', flag=1 where flag=0 and city like '%" + newcituname + "%' ORDER BY LOCALITY DESC limit 100 ";
               LeptonDataLayer.ExecuteNoneQuery(1, SqlQuery);







但是当我运行它时会产生如下错误



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




but when i m run it it give following error like this

""Object reference not set to an instance of an object.""

推荐答案

SqlConnection cn = new SqlConnection("ConnectionString");
           string SqlQuery = "Update tableName set  assignedtouserid='" + frmmain.UserName + "', flag=1 where flag=0 and city like '%" + newcituname + "%'";
           SqlCommand cmd = new SqlCommand(SqlQuery, cn);
           cn.Open();
           cmd.ExecuteNonQuery();


这篇关于我有以下错误请帮我解决它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 10:08