使用存储过程插入,更新,删除操作,并在表单字段中检索数据以进行操作 [英] Insert, update, delete operation with stored procedure and retrieve data in form fields for operation

查看:94
本文介绍了使用存储过程插入,更新,删除操作,并在表单字段中检索数据以进行操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在这里新建。

我创建了c#windows应用程序,我使用存储过程进行插入,删除,更新操作我希望在数据库中看到的任何验证。现在我不使用datagrid或任何东西。

现在的问题是如何使用存储过程在Windows窗体中检索保存数据?



i创建简单的Item Master页面,只需要在字段中的页面加载上检索上次保存的数据。



请帮帮我。



我的尝试:



i创建项目主文件的存储过程。

i创建插入存储过程。



现在,当我插入记录并单击保存按钮时,它将记录保存在数据库中。我不需要datagrid来查看数据库记录。



如何使用存储过程从数据库加载最后插入的记录?

hello ,
i new here.
i create c# windows application, i use stored procedure for insert,delete,update operation any validation i want to see in database. now i am not use datagrid or anything .
Now the question is How can i retrieve save data in windows form using stored procedure?

i create simple Item Master page , only need to retrive last saved data on page load in fields.

pls help me.

What I have tried:

i create stored procedure of item master.
i create insert stored procedure.

now when i insert record and click on save button it save record in database. i no need datagrid to see record of database.

how can i load last inserted record from database using stored procedure?

推荐答案

要做的第一件事是确保您的数据库包含时间戳列 - 最简单的方法是在表中添加DATETIME列,并将其DefaultValue设置为 GETDATE()。这样,无论何时INSERT数据,时间戳都将设置为服务器时间。

然后存储过程是微不足道的:

The first thing to do is to make sure that your DB includes a timestamp column - the easiest way to do this is to add a DATETIME column to your table, and set it's DefaultValue to GETDATE(). That way, whenever you INSERT data, the timestamp will be set to the server time.
Then the Stored Procedure is trivial:
CREATE PROCEDURE GetLatestRow 
AS
BEGIN
	SELECT TOP 1 ColumnIWant, OtherColumnIWant FROM MyTable ORDER BY TimestampColumn DESC;
END


这篇关于使用存储过程插入,更新,删除操作,并在表单字段中检索数据以进行操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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