How can I store data in sql database using asp.net c# [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question 开发者_如何转开发Does someone have the code to write/store data from asp.net c# to a sql database?
There are so many ways you can write/store data to sql database. But to give you a heads start you can check this out
http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx
set varchar(50)
or date any SQL Datatype, in SQL Server
In webform set calander control name "Calander1"
then,
try This Code to save Date into SQL:
try
{
string Releasedate = Calendar1.SelectedDate.Date.ToString();
SqlCommand cmd = new SqlCommand("INSERT INTO mydb (date) VALUES ('"+Releasedate+"')", sqlcon);
sqlcon.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
finally
{
sqlcon.Close();
}
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery.aspx
As others have said, your question is a very generic. But a very basic way to select, insert, update and delete data to a sql server database is through SqlCommand object. The site given here will give you an idea of the same. This site also contains sample code.
精彩评论