如何使用ADO.net连接导向模式在SQL数据库的表中插入一行 [英] how to insert a row in table of SQL Database using ADO.net connection oriented mode

查看:75
本文介绍了如何使用ADO.net连接导向模式在SQL数据库的表中插入一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,其中一个表的名称为Registration,用于注册用户。

它只有两个第一列是用户名,一个是密码。

一个名为Register.aspx的页面用于注册有两个成员textbox one用于获取用户名(textbox1),一个用于获取密码(textbox2)和一个用于在数据库中插入这些值的按钮。

主要问题是我们不能写这样的语句:



I have a database in which a table has name "Registration" which is used to register the user.
It has only two column one is "Username" and one is "password".
A page named "Register.aspx" is used for registering the member which have two textbox one is for taking Username(textbox1) and one is for taking password(textbox2) and one button for insert these value in database.
The Main problem is that we cannot write statement like this :

Insert into Registration (Username, password) values     ('TextBox1.text','TextBox2.text')





我正在使用ADO.net连接导向模式,我googled但我没有找到任何方式在连接模式下插入SQL数据库中的行。请给我一个插入这一行的想法?



I am using ADO.net Connection oriented mode , i googled but i didnt find any way to insert row in SQL database in connected mode. Please provide me a idea for inserting this row?

推荐答案

看看:SqlCommand.Parameters [ ^ ] - 该示例显示了如何执行操作 - 包括使用参数将值传递给服务器。



您还可以查看: C#Station ADO.NET Tutorial [ ^ ]



最好的问候

Espen Harlinn
Have a look at: SqlCommand.Parameters[^] - the example shows how to perform the operations - including the use of parameters to pass values to the server.

You could also have a look at: C# Station ADO.NET Tutorial[^]

Best regards
Espen Harlinn


这篇关于如何使用ADO.net连接导向模式在SQL数据库的表中插入一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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