使用C#编码的asp.net将数据插入Web应用程序的sql数据库中 [英] asp.net using c# coding for insert data into sql database for web application

查看:148
本文介绍了使用C#编码的asp.net将数据插入Web应用程序的sql数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c#编码在asp.net中完成我的mca年度项目.这是基于Web的项目.实际上,我需要将数据插入数据库的编码.

i am doing my mca final year project in asp.net using c# coding. this is the web based project. actually i need the coding for inserting the data to database.

推荐答案

任何ADO.Net本书都可以告诉你.并且由于您正在执行MCA,所以我假设您有一个.因此,剩下的就是阅读它.
Any ADO.Net book would tell that. And since you are doing MCA, I assume you have one. So, only thing left is reading it.


请参阅下面的链接


http://msdn.microsoft.com/en-us/library/e80y5yhx(VS .71).aspx [ ^ ]

http://www.csharp-station.com/Tutorials/ADODotNet/Lesson01.aspx [ ^ ]
Refer the links below


http://msdn.microsoft.com/en-us/library/e80y5yhx(VS.71).aspx[^]

http://www.csharp-station.com/Tutorials/ADODotNet/Lesson01.aspx[^]


创建数据库,创建连接,然后在您的项目中使用此代码插入数据


Create database, create connection, and then use this code in your project to insert the data


<br />
string connStr = "Data Source=.;Initial Catalog=DatabaseName;Integrated Security=True";<br />
SqlConnection dbCon = new SqlConnection(connStr);<br />
SqlCommand sqlCmd;<br />
DataTable dbTbl;<br />
SQLCommand sqlCmd;<br />
sqlCmd = new SqlCommand();<br />
dbCon.Open();<br />
sqlCmd.CommandType = CommandType.StoredProcedure;<br />
sqlCmd.Connection = connStr ;<br />
sqlCmd.CommandText = ("INSERT INTO TABLE NAME VALUES(A,B,C) ");<br />
sqlCmd.ExecuteNonQuery()<br />
dbCon.Close();<br />



使用此代码,您将插入您的数据



use this code and u will get inserted your data


这篇关于使用C#编码的asp.net将数据插入Web应用程序的sql数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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