且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用SQL CRUD将数据添加到数据库?

更新时间:2023-02-07 10:49:59

Failed to convert parameter value from a String to Int32


这意味着您将字符串传递给SQL,但是数据库中的字段是Int32.

实际上,这很简单:


This implies that you handing the string to SQL, but the field in the database is an Int32.

In fact, it''s simple:

cm.Parameters["@FilmID"].Value = 34;
cm.Parameters["@FilmName"].Value = "Inception";
cm.Parameters["@FilmID"].Value = "Action/Thriller";

更改最后一行:

Change the last line:

cm.Parameters["@FilmID"].Value = 34;
cm.Parameters["@FilmName"].Value = "Inception";
cm.Parameters["@FilmGenre"].Value = "Action/Thriller";