ASP.NET:错误 - 列名或提供的值数量与 table 定义不匹配

ASP.NET : Error - Column name or number of supplied values does not match table definition

我正在处理 ASP.NET 网络应用程序项目。在我的注册页面中,我要求用户上传照片,但是当我尝试上传时,此错误显示在浏览器的第 83 行:

Line 81:                 comm.Parameters.AddWithValue("@License", License);
Line 82:                 conn.Open();
Line 83:                 int row = comm.ExecuteNonQuery();
Line 84:                 conn.Close();
Line 85:                 if (row > 0) { LabelError.Text = "DONE"; }

我的数据库 table :

CREATE TABLE [dbo].[DeliveryMen] (
    [Delivery_ID] INT             IDENTITY (1, 1) NOT NULL,
    [Name]        NVARCHAR (50)   NOT NULL,
    [Username]    NVARCHAR (50)   NOT NULL,
    [Password]    NVARCHAR (50)   NOT NULL,
    [Email]       NVARCHAR (50)   NOT NULL,
    [Phone]       NVARCHAR (50)   NOT NULL,
    [City]        NVARCHAR (50)   NOT NULL,
    [License]     VARBINARY(MAX) NOT NULL,
    [Latitude]    NUMERIC (18)    NOT NULL,
    [Longitude]   NUMERIC (18)    NOT NULL,
    PRIMARY KEY CLUSTERED ([Delivery_ID] ASC)
);

如果您需要插入功能:

 public void insert()
        {

            if (FileUpload1.PostedFile.FileName != "")
            {
                byte[] License;
                Stream s = FileUpload1.PostedFile.InputStream;
                BinaryReader br = new BinaryReader(s);
                License = br.ReadBytes((Int32)s.Length);
                 SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDatabase"].ConnectionString);
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = "insert into DeliveryMen values(@License) SELECT '7'";
                comm.Parameters.AddWithValue("@License", License);
                conn.Open();
                int row = comm.ExecuteNonQuery();
                conn.Close();
                if (row > 0) { LabelError.Text = "DONE"; }
            }
            else LabelError.Text = "Please upload the photo";
        }

正如评论中提到的 Soner Gönül,更改您的 SQL 以列出 column name(s)parameter value(s)

comm.CommandText = "insert into DeliveryMen (License) values (@License);";