使用SaveFileDialog将Image保存到SQL Server数据库中

问题描述:

嗨我有一个名为rdoFP_JD的radioButton,它使用SaveFileDialog来选择图片。我想知道在开始插入命令后如何将选择的图像文件存储到数据库中。



Hi i Have a radioButton called rdoFP_JD, which is using a SaveFileDialog to select a picture. I want to know how to store that image file selected into the database once it begins the insert command.

insertCommand.Parameters.AddWithValue("@ASAM_FIRMA", SqlDbType.Image).Value = rdoFP_JD.Image





我已经尝试过这个但它给了我这个错误



参数化查询''(@ASAm_FECHA datetime,@ ASAS_VER

nvarchar(60,@ ASAS_LUGAR nvar''表示参数

''@ ASAm_FIRMA_PRES_JD'',未提供。



谢谢。



I have already tried with this but it gives me this error

The parameterized query ''(@ASAm_FECHA datetime, @ASAM_VER
nvarchar(60, @ASAM_LUGAR nvar''expects the parameter
''@ASAm_FIRMA_PRES_JD'', which was not supplied.

Thanks.

您提供的错误消息表明预期参数为@ ASAm_FIRMA_PRES_JD''但您在示例代码中显示您将参数名称设置为ASAM_FIRMA。



添加参数时使用的名称必须为匹配SQL的名称服务器期望。_ PRES_JD在SQL Server期望的末尾,但在调用AddWithValue方法时不在参数名称的末尾。
The error message that you provided says that the expected parameter is "@ASAm_FIRMA_PRES_JD'' but you show in your example code that you are setting the parameter name to "ASAM_FIRMA".

The name that you use when you add the paramater has to match the name that the SQL Server expects. "_PRES_JD" is on the end of what the SQL Server expects but is not on the end of the parameter name when you call the AddWithValue method.