我在這一行int number = int.Parse(Days);
型鑄造收到錯誤 - 輸入字符串的不正確的格式
輸入字符串的不正確的格式得到一個錯誤。
public string GetApprovedLimit(int CategoryId)
{
SqlConnection connection = new SqlConnection(GetConnectionString());
SqlCommand cmdLog = new SqlCommand();
cmdLog.CommandType = CommandType.StoredProcedure;
cmdLog.Connection = connection;
cmdLog.Transaction = Trans;
connection.Open();
cmdLog.CommandText = "ApprovedDays";
cmdLog.Parameters.AddWithValue("@CategoryId", CategoryId);
string Days = cmdLog.ExecuteScalar() == null ? "1" : cmdLog.ExecuteScalar().ToString();
connection.Close();
int number = int.Parse(Days);
Days = (number + 20).ToString(); // Added extra 20 days for late link submission
return Days;
}
存儲過程:
Create Proc [dbo].[ApprovedDays]
(
@CategoryId int
)
as begin
select ApprovedDays from tbl_Category where [email protected]
end
GO
什麼是'Days'到底是什麼?你調試了你的代碼並檢查它嗎? –
條件運算符執行兩次查詢。將其存儲在一個變量中。 –
顯示完整的代碼。 –