我有我創建了一個表 「CampWheelDenominationno」,我有一個特定行「配額」如何從數據庫中統一添加值列表
我需要數據的基礎上當「配額」 變爲零時,相應「配額」的「slno」。
我的SQL代碼,這樣做是
"select slno from CampWheelDenomination where quota_allowded = 0"
現在我需要添加這些「slno」到list..i已經做的方法我自己,但t不與工作
public int checkCodeinDb() { using (IDbConnection dbConnection = new SqliteConnection (connectionString)) { dbConnection.Open(); using (IDbCommand dbCmd = dbConnection.CreateCommand()) { string sqlQuery = "select slno from CampWheelDenomination where quota_allowded = 0"; dbCmd.CommandText = sqlQuery; using (IDataReader reader = dbCmd.ExecuteReader()) { while (reader.Read()) { //slnolist is a list i have created at begining SlNoList.Add (reader.GetString (0)); } return slnolist ; //error at here foreach (string st in SlNoList)// i have done this to check whether the slno is added to the list. { print (st); } dbConnection.Close(); reader.Close(); } } } }
如何從DATABSE添加這些slno到SlNOList
錯誤是不能隱轉換類型System.Collections.Generic.List<string>' to
int'發生在線返回SlNoList
什麼是錯誤? –
如果你正在定義'SlNoList',你是否實例化了這個變量? –
slnolist是我之前創建的一個列表 –