-4
我添加了一个文本框和一个按钮下面为什么这个查询不起作用?
<asp:Label ID="Label1" runat="server" Text="Email'e Göre Silin"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Sil" />
,但我的查询是不是这些工作。
SqlConnection con = new SqlConnection("Data Source=DESKTOP-VQUBBVP\\SQLEXPRESS; initial catalog=UgurBocegiDatabase; Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("delete from tblMessage where Email = '"+TextBox1.Text+ "' ", con);
cmd.ExecuteNonQuery();
我试着添加下面的.tostring方法,但它没有再次工作。
SqlCommand cmd = new SqlCommand("delete from tblMessage where Email = '"+TextBox1.Text.ToString()+ "' ", con);
和查询SQL Server中的作用类似于下面
delete from tblMessage where Email = 'gs213'
是什么问题?
**警告**您的代码非常容易受到sql注入攻击 –
永远不要在家里做这个,孩子。 – TigOldBitties
阅读[问]并详细说明“不起作用”。 – CodeCaster