下面是我對這種方法的代碼。我想處理我正在使用的數據庫中的Active列,但是我得到這個「Active」不屬於表的錯誤。這顯然在表中,並且我在RestartData.cs中用屬性定義了它。在數據庫中,我將它設置爲一點而不是布爾值。我想知道這是否是問題所在。 1爲真,0爲假。我通過谷歌研究了這一點,但無法找到任何關鍵點。任何幫助將不勝感激。「Column」不屬於表
static List<RestartData> AppRestartList()
{
List<RestartData> restartDatas = new List<RestartData>();
RestartData restartData = null;
string sqlQuery = "Select RestartTime, ProgramLocation, LastRestartTime, RestartInterval, ProgramServer, RestartIfRunning, ProcessName from dbo.anyDatabase where active=1;";
//execute sql query
//execute database reader
SqlCommand command = new SqlCommand(sqlQuery, (SqlConnection)DB.MakeConnection("any_database"));
DataTable dt;
command.Connection.Open();
dt = DB.ExecuteTable(command, "any_database");
foreach (DataRow row in dt.Rows)
{
//move stuff from reader into log data, and exp
//not RestartData restartData = new RestartData(); The RestartData() method is already declared
restartData = new RestartData();
restartData.ProgramLocation = Misc.NullSafeString(row["programLocation"]);
restartData.Active = Misc.NullSafeBool(row["active"]);
restartData.RestarInterval = Misc.NullSafeInt(row["restartInterval"]);
restartData.RestartIfRunning = Misc.NullSafeBool(row["restartIfRunning"]);
restartData.ProcessName = Misc.NullSafeString(row["processName"]);
restartData.LastRestartTime = Misc.NullSafeDateTime(row["lastRestartTime"]);
//add restartData to list
restartDatas.Add(restartData);
}
return restartDatas;
}
問題標題沒有意義。 – M4N
我之所以這麼用,是因爲Google中的任何內容都不會在NullSafeBool上進行搜索而返回,因此我爲可能正在查找的下一個人做了 – webby68
但問題與NullSafeBool()方法無關 – M4N