-1
forループを使用してデータセットにデータセット値を追加することができません。コードを見て助けてください。予想されるint32のようなエラーをスローします。タイプ 'System.Data.DataRow'のオブジェクトを 'System.IConvertible'にキャストすることができません。regidに<System.Data.DataRow>を格納できません。列
string allCtries = string.Empty;
allCtries = com.COUNTRY_ID;
string[] splitctrs = new string[] { };
splitctrs = allCtries.Split(',');
string m_Query = string.Empty;
DataSet dsPck = new DataSet();
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("regid", typeof(int)),
new DataColumn("cid", typeof(int)),
new DataColumn("pid", typeof(int)) });
foreach (string val in splitctrs)
{
dsPck = con.GetDataSet("select registrationid, country_id, product_id from registration where product_id = " + com.PRODUCT_ID + " and country_id = " + val + "", CommandType.Text, ConnectionState.Open);
DataRowCollection drr = dsPck.Tables[0].Rows;
foreach (var row in drr)
dt.Rows.Add(row);
//if (dsPck.Tables[0].Rows.Count> 0)
//{
// dt.Rows.Add(dsPck);
//}
}
すでに代わりにint型使用のInt32をしようと試みたことがありますか? – Sergio
はい.iもint32、int64を試しましたが、エラーをスローします。 – Ayyappa
はこの場所にエラーをスローします。dt.Rows.Add(row); – Ayyappa