Retrieve ODBC table and Insert into SQL Server CE database

本秂侑毒 提交于 2019-12-05 16:03:40

Change this part of your code

commandD.Parameters.Add("@sql",SqlDbType.NVarChar, 5); 
while (reader.Read()) 
{ 
  string x = reader[0].ToString();                   
  commandD.Parameters["@sql"].Value = x ;
  commandD.ExecuteNonQuery();      
} 

The problem arises because, in every loop, you repeat the add of the same named parameter to the collection resulting in the error above.
Moving the creation of the parameter outside the loop and updating only the value inside the loop should resolve the error.

Yes, I think you have posted the question correctly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!