"if (period.Tostring() ="1 year ")"문제는 데이터베이스 nvarchar를 검사하고 변환해야하므로 루프를 수행하지만 빨간색으로 표시됩니다. 선.if 문에 빨간색 줄이있는 경우
string strCommandText4 = "SELECT autoLoanPeriod From AutoLoan WHERE userID= '" + Session["userID"] + "';";
SqlCommand myCommand4 = new SqlCommand(strCommandText4, myConnection);
var period = myCommand.ExecuteScalar();
if (period.ToString() = "1 year")
{
for (int i = 0; i<= 12; i++)
{
string strCommandText5 = "INSERT INTO AutoTrans VALUES(@loanID,@transPeriod,null,@transStatus);";
SqlCommand myCommand5 = new SqlCommand(strCommandText5, myConnection);
myCommand5.Parameters.AddWithValue("@loanID", Session["@loanID"].ToString());
myCommand5.Parameters.AddWithValue("@transPeriod", numPeriod);
myCommand5.Parameters.AddWithValue("@transStatus", status);
}
}
은''== 항등 연산자이다 =''할당 연산자이다. –