【发布时间】:2018-03-20 07:13:03
【问题描述】:
我正在研究自动生成代码收据编号。这是我的代码:
var conrecipt = new SqlConnection(
ConfigurationManager.ConnectionStrings["con"].ConnectionString);
conrecipt.Open();
var cmd = new SqlCommand("Select COALESCE(MAX(Reciptno),0) from Registration", conrecipt);
int i = Convert.ToInt32(cmd.ExecuteScalar());
conrecipt.Close();
i++;
Label3.Text = Reciptno + i.ToString();
一切正常。但我需要检查 3 个表:Registration、Advance 和另外一个表,并且需要从这些 id 中找到最大值。
如何在 Asp.Net C# 和 MS SQL Server 2012 中执行此操作?
【问题讨论】:
-
这是一个有缺陷的设计,势必会给你带来越来越多的问题,尤其是在多用户环境中
-
这感觉像是一个 XY 问题 - meta.stackexchange.com/questions/66377/what-is-the-xy-problem。 为什么你需要这样做?
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
标签: c# sql asp.net sql-server