내 데이터베이스에 저장된 사용자 데이터를 업데이트 할 수 없습니다.C에서 업데이트 sql 명령 #
내가하는 버튼을 생성 한 다음 C# 코드 여기
를 추가 한 내 영문 코드 : 내가 업데이트 명령 "사용자 업데이트"를 시도하고 다음 "이름을 설정"
table class="logintable" border="0" cellpadding="0" cellspacing="0">
<tr>
</tr>
<tr>
<td>
Fornavn
</td>
<td>
<asp:TextBox ID="txtFornavn" runat="server" />
</td>
<td>
<asp:Button ID="Button1" Text="Update" runat="server" OnClick="Button1_Click" />
</td>
<td>
</td>
</tr>
</table>
여기 당신이 찾고있는 무슨이 아마 내 C# 코드
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=testingDB;User id=sqluser2;Password=password01;"))
{
SqlCommand command1 = new SqlCommand("UPDATE Bruger SET Fornavn='" + txtFornavn.Text + "' where Email='"+ Session["Email"] + "';",con);
//SqlCommand command1 = new SqlCommand();
//command1 = con.CreateCommand();
//command1.CommandText = "UPDATE Bruger set fornavn='" + txtFornavn.Text+ "' where email='" + Session["email"] + "';";
command1.Parameters.AddWithValue("@Fornavn", txtFornavn.Text);
command1.Connection.Open();
command1.ExecuteNonQuery();
con.Close();
무엇이 묻습니까? – TheGameiswar
txtFornavn.Text에 의한 SQL 주입 경고, 거기에 매개 변수가있는 것처럼 보입니다. – SCFi
전자 메일이''OR 1 = 1 -'인 경우 어떻게합니까? –