Alessandro Minneci Alessandro Minneci - 2 years ago 85
SQL Question

How can I save my Textbox content in a database? Textbox is programmed in HTML and CSS

I have a fully finished Frontend of my Web Application, now i have to save the textbox content in my Database(SQL) wich i created in VisualStudio.

My ConnectionString is already programmed
enter image description here
I coded my textbox as following:

enter image description here

How do i have to integrate my C# in my Html code so it saves my Content?

Thanks for your time <3

Answer Source

Use this in whichever event you want it to execute in:

string con = //your connection string here
string yourTextValue = Passnummer.Text; //This will extract the text from your textbox and store it in a variable
using (string con = new SqlConnection()) {

var command =
    new SqlCommand("INSERT INTO yourTable(columnname) VALUES (@textValue);", con);
command.Parameters.AddWithValue("@textValue", yourTextValue);


See Here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download