为什么这个Sql代码不正确? [英] Why this Sql code is not true ?

查看:81
本文介绍了为什么这个Sql代码不正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

Cmd = new SqlCommand(UPDATE BillNumber SET BillNumb = BillNumb +1 WHERE Id = 1;);

cn.Open( );

Cmd.ExecuteNonQuery();

cn.Close();

This is my code :
Cmd = new SqlCommand("UPDATE BillNumber SET BillNumb = BillNumb +1 WHERE Id=1;");
cn.Open();
Cmd.ExecuteNonQuery();
cn.Close();

推荐答案

给定分钟你提供的信息量,我只留下推测。但是,我的猜测是你从未发起过该命令的连接。所以做两件事之一:



1.

Given the minute amount of information you have provided, I am left only to speculate. But, my guess is that you never initiated a connection for the command. So do one of two things:

1.
Cmd = new SqlCommand("UPDATE BillNumber SET BillNumb = BillNumb + 1 WHERE Id = 1",ConnectionString);







2.


or

2.

Cmd.Connection = "Your connection string";


这篇关于为什么这个Sql代码不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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