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
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.
Display(ID +"Record Successfully Added ")
how i can populate ID of added record in my Display?
PS: i'm using Sql Ce and queries i'm using Adapter to generate them and call them
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)
and this Identity(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 ;
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.