I am just learning .net and I would like to know how to write a simple program to get the data that was inputted into a textbox and save it to an SQL DB.
Ok, bare bones, simple as spit webforms text box to save into a database using simple ado.net. Bear in mind that nowadays the entity framework is the preferred way to work with a database, but that would make this simple task seem a lot more complicated.
The web form markup
Dim con As New System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("EETest").ConnectionString) con.Open() Dim sql As String = "INSERT INTO SaveText (Text) VALUES (@Text)" Dim command As New System.Data.SqlClient.SqlCommand(sql, con) command.Parameters.AddWithValue("@Text", txtSaveThis.Text) command.ExecuteNonQuery()
Have you searched for any tutorials on the subject? There are countless examples on the subject. Furthermore, ASP.NET is a broad term these days. There is Web Forms and MVC. Which are you using?
0
huerita37Author Commented:
I actually don't know. Just trying to learn.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
The web form markup
Open in new window
and the code behind
Open in new window
If you have an issue with the ConfigurationManager you will need to add a reference to System.Configuration.