0
이해가 안됩니다. 이 코드는 제대로 작동 할 것입니다.SQL Server 데이터베이스에서 새 정보를 업데이트하지 않습니다.
내가 잘못 한 것을 누구든지 볼 수 있습니까?
public static int InsUpDel(string str)
{
if (!(conn.State == ConnectionState.Open))
conn.Open(); //open connection if closed
int numRows = 0; //counter that checks number of rows affected in the db
try
{
SqlCommand cmd = new SqlCommand(str, conn);
numRows = cmd.ExecuteNonQuery();
cmd = null;
}
catch (SqlException ex)
{
string errorMsg = ex.Message; //more code can be put here
}
if (conn.State == ConnectionState.Open)
conn.Close();
return numRows;
}
감사합니다 :
string username = tbNewUSER.Text.Trim();
string password = tbNewPass.Text.Trim();
string role = "USER";
string str = "insert into UserValidation (USERNAME, PASSWORD, ROLE) values ('" + username + "','" + password + "','" + role + "')";
MessageBox.Show(username + " Registered", "User registration",MessageBoxButtons.OK, MessageBoxIcon.Information);
clsDB.InsUpDel(str);
는 그리고 이것은 후속이다.
을 "는 작동하지"왜이 마지막 하나는 알아내는 데 도움이 될 것입니다. 그렇지 않으면 생성 된 쿼리를 실행 해 보셨습니까? – Stephen
시도/따라 잡기를 시도 했습니까? – Snowlockk
추가 메모로 변경 내용이 커밋되기 전에 성공 메시지를 표시하지 마십시오. – Stephen