如何使用C#和SQL在文本框中显示StudentID [英] How can show studentid in textbox using c# and sql

查看:56
本文介绍了如何使用C#和SQL在文本框中显示StudentID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,
我创建了带有学生ID列的sql表作为自动隐藏列.现在我想显示从sql到文本框的ID.在插入数据之前,表上没有ID.当时我想在文本框中显示第一个值",然后为每次插入显示sql表中的下一个自动递增的值.请帮我该怎么做.
在此先感谢

Hi friends,
I created sql table with studentID column as a autoincreamented column.now I want to show the Id from sql to textbox.Before any insertion of data there is no Id on the table. At that time I want show First value in textbox and then show next autoincremented value from sql table for every insertion.Plase help me how can i do this.
Thanks in advance

推荐答案

Don''t.
停下来想一想.
您为什么要显示所有价值?这样人们就可以知道他们正在创建的新记录将获得什么价值.但是使用SQL的主要原因是它同时支持多个用户,因此下一个值"将不是下一个-该值可能是两个小时前另一个用户使用的.

这会导致混乱-仅在正确时才显示信息-在自动递增数据的情况下,仅在正确插入记录后才显示.

如果需要为用户提供记录ID,则您的数据设计可能存在问题.
Don''t.
Stop and think about it.
Why are you showing the value at all? So that people know what value will be assigned to the new record they are creating. But the main reason for using SQL is that it supports multiple users at the same time, so the "next value" won''t be the next one - that value may have been used by a different user two hours ago.

That leads to confusion - only show information when it will be correct - which in the case of auto incremented data is only after the record has been inserted correctly.

If you need to give the user the record id, then there is probably something wrong with your data design.


这篇关于如何使用C#和SQL在文本框中显示StudentID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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