-4
여기 새내기. 조언이 필요합니다. 데이터베이스에 값을 삽입하고 코드에 오류를 넣고 싶습니다. 그 다음은 데이터베이스데이터베이스에 값을 삽입하는 방법
내 코드 가 저장이 작업을 수행 : 수행대로해서는 안하려고 노력하는 모든
string Constr = @"Data Source=(local);Integrated Security=True;Database=DDLYBank";
SqlConnection Conn = new SqlConnection(Constr);
string MainAccInfo = "Select AccountNo, HashValue from MainAcc Where HashValue = '" + ccinfo + "'";
SqlCommand cmd1 = new SqlCommand(MainAccInfo, Conn);
SqlDataReader read1 = cmd1.ExecuteReader();
using (SqlCommand command = Conn.CreateCommand())
{
command.CommandText = "Insert INTO Record (AccountNo, HashValue, Debit, Balance, Date_Time, FingerPrint) Values (@AccountNo, @HashValue, @Debit, @Balance, @Date_Time, @FingerPrint)";
command.Parameters.AddWithValue("@AccountNo", read1["AccountNo"]);
command.Parameters.AddWithValue("@HashValue", read1["HashValue"]);
command.Parameters.AddWithValue("@Debit", rDebit);
command.Parameters.AddWithValue("@Balance", aBalance);
command.Parameters.AddWithValue("@Date_Time", rDate);
command.Parameters.AddWithValue("@FingerPrint", rFingerPrint);
Conn.Open();
command.ExecuteNonQuery();
}
}
catch (SqlException ex)
{
return;
}
당신은 SQL 명령에 매개 변수 이름 앞에 @ 기호가 누락되었습니다. –
이 말씀이신가요? "@AccountNo" 나는 그것을 시도했다. 아직도 내가 그것을했을 다른 캔트. –
예외가 있습니까? – Jodrell