插入数据库的最佳方法 [英] Best method to insert into database

查看:91
本文介绍了插入数据库的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
将数据插入数据库的最佳方法是哪种?
我正在将MSSQL和ASP.NET与C#一起使用

请帮忙! :confused:

Dear all,
Which is the best method to insert data into the database?
I am using MSSQL and ASP.NET with C#

Please help! :confused:

推荐答案

1-在数据库中创建存储过程,并通过传递所需的参数将其用于数据库操作.

2-如果您不习惯编写存储过程,并且想编写直接查询,那么在这种情况下,请使用参数化查询.


3-为了更好地管理连接/命令/事务等,可以在C#中使用企业库的数据块.
1- Create stored procedure in the database and use them for database operations by passing desired parameters.

2- It you are not comfortable in writing stored procedures, and want to write direct query then in that case use parameterized queries.


3- For managing connections/command/transactions etc in better way, in C# you can use Data Block of Enterprise Library.


如果您在Visual Studio 2008(Framework 3.5)中工作,请使用Linq.它非常易于使用,我们可以在某些行中执行操作,而且速度也很快.
If you are working in Visual Studio 2008(Framework 3.5) then use Linq. it is very simple to use and we can perform operations in some lines and it is also fast.


这篇关于插入数据库的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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