如何将我的文本框内容保存在数据库中?文本框在 HTML 和 CSS 中编程
How can I save my Textbox content in a database? Textbox is programmed in HTML and CSS
我有一个完全完成的 Web 应用程序前端,现在我必须将文本框内容保存在我在 VisualStudio 中创建的数据库 (SQL) 中。
我的 ConnectionString 已经编程
Image
我将我的文本框编码如下:
My Code
我如何将我的 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();
}
见Here
我有一个完全完成的 Web 应用程序前端,现在我必须将文本框内容保存在我在 VisualStudio 中创建的数据库 (SQL) 中。
我的 ConnectionString 已经编程 Image 我将我的文本框编码如下:
My Code
我如何将我的 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();
}
见Here