로 입력하십시오.복제본을 확인하여이 코드를 입력하여
private void button1_Click(object sender, EventArgs e)
{
string Coonstring = "datasource=localhost;port=3306;username=root;password=****;Charset=utf8";
string cmd = "Insert into project.name_registry (name) values('" + this.txt.Text + "');";
MySqlConnection connectionDatabase = new MySqlConnection(Coonstring);
MySqlCommand cmddata = new MySqlCommand(cmd, connectionDatabase);
MySqlDataReader myreader;
try
{
connectionDatabase.Open();
myreader = cmddata.ExecuteReader();
MessageBox.Show("Done");
while (myreader.Read())
{
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
나는이 버튼 체크에 눌러 삽입 이름을 메시지 박스 내 이름이 존재 말해 추가를 방지 표시가 발견되면 때 필요합니다. 삽입 완료라고하지 않으면. 어떻게 할 수 있니? 이전에 언급 한 바와 같이
감사합니다 첫째
** 경고 ** 귀하의 코드는 SQL 주입 공격에 매우 취약합니다. –
두 번째로, EntityFramework에 대해 들어 봤습니까? 모든 질문을 해결할 것입니다. :) –
'name = regime에서 count (*)를 선택하십시오. [name] = 'TheName'' 그리고 위에서 언급 한 것처럼 SQL 주입을 감시하십시오. –