繁体   English   中英

如何将我的文本框内容保存在数据库中? 文本框使用HTML和CSS编程

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

我已经完成了Web应用程序的前端,现在必须将文本框内容保存到在VisualStudio中创建的数据库(SQL)中。

我的ConnectionString已经设定图片我编写我的文本框,如下:

我的密码

我如何将C#集成到HTML代码中以保存内容?

感谢您的时间<3

无论您希望在哪个事件中执行此事件,都可以使用它:

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()) {
con.Open();

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

command.ExecuteNonQuery();
con.Close();
}

这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM