「 if (period.Tostring() = "1 year") 」の問題は、データベース nvarchar をチェックして、変換する必要があるためループを実行したかったのですが、赤い線が表示されました。
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);
}
}