通过ASP.Net设计的网页将数据插入SQL Server数据库的过程 [英] Data insert process to SQL Server Database through web page which design with ASP.Net

查看:583
本文介绍了通过ASP.Net设计的网页将数据插入SQL Server数据库的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过SQL Server数据库表中的网页输入数据(名称和电子邮件).
我在ASP.Net应用程序设计中附加了两个文本框和一个提交按钮.现在,我想知道Submit按钮的详细事件.

I want to enter data (Name and Email) through web page in SQL Server database table.
I attach two text box and a submit button in my ASP.Net application design. Now I want to know the details event of Submit button.

推荐答案

尝试一下....

Try this....

string InsertQuery = "insert into [tablename](column1,column2) values (@param1,@param2)";
        try
        {
            SqlConObject.Open();
            SqlCommand cmd = new SqlCommand(InsertQuery, SqlConObject);
            cmd.Parameters.AddWithValue("@param1", TextName.Text.Trim());
            cmd.Parameters.AddWithValue("@param2", TextEmail.Text.Trim());
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();
        }
        finally
        {
            SqlConObject.Close();
        }


问候
Ashish


Regards
Ashish


以下应该可以帮助您:
通过C#访问SQL Server的入门指南 [ ^ ]
简单的ADO.NET数据库读取,插入,更新和删除使用C#. [ ^ ]

阅读,学习,尝试!
Following should help you out:
Beginners guide to accessing SQL Server through C#[^]
Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]

Read, learn, try!


这篇关于通过ASP.Net设计的网页将数据插入SQL Server数据库的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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