简体   繁体   English

从数据库2检索数据

[英]Retrieving data from database #2

I have the below command to Insert(Name,Family,Address) value in my Table ( ID,Name,Family,Address) I'm using Data Set and Data Adapter 我使用以下命令在表(ID,名称,家庭,地址)中插入(名称,家庭,地址)值(我正在使用数据集和数据适配器)

 stdDataSetTableAdapters.studentTableAdapter da = new stdDataSetTableAdapters.studentTableAdapter();
 da.InsertCard("Albert", "Alexis","No4.London");

It work and it add the new row of data in my database : but here is a problem after inserting i want to Display something like that : the ID(primary key ) and one Message. 它可以正常工作,并在数据库中添加新的数据行:但是插入后,这是一个问题,我想显示类似的东西:ID(主键)和一条消息。

Display(ID +"Record Successfully Added ")

how i can populate ID of added record in my Display? 如何在我的显示器中填充已添加记录的ID?

PS: i'm using Sql Ce and queries i'm using Adapter to generate them and call them PS:我正在使用Sql Ce和查询我正在使用适配器生成它们并调用它们

Take a look at this example 看这个例子

INSERT INTO Employee (EmpName,Emp_level,Emp_Sal) VALUES ('Chris', 25B, 54000);

SELECT Emp_id FROM jobs Employee Emp_id = @@IDENTITY;

for More info see this Identity(SQl Authority) 有关更多信息,请参见此身份(SQl授权)

and this Identity(MSDN)) 和这个身份(MSDN)

as an alternative solution to Identity one could use MAX() as well a simple syntax would be like SELECT MAX(Emp_id) FROM Employee ; 作为Identity的替代解决方案,可以使用MAX()以及简单的语法,例如SELECT MAX(Emp_id) FROM Employee ; Hope this Helps 希望这可以帮助

please try the following Queries it may help you, 请尝试以下可能对您有帮助的查询,

SELECT Top1 Emp_id FROM jobs Employee Emp_id = @@IDENTITY; 

SELECT Max Emp_id FROM jobs Employee Emp_id = @@IDENTITY; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM