本文介绍了如何修复这个错误..'没有给出一个或多个必需参数的值'。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void btnSubmit_Click(object sender, EventArgs e)
{
byte[] picbyte = System.IO.File.ReadAllBytes(textBox.Text);
try
{
string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\\PIS(ACU).mdb;";
Con = new OleDbConnection(@constr);
Con.Open();
Com = new OleDbCommand();
Com.Connection = Con;
Com.CommandText = "INSERT INTO PatientImages (Patient_Id,ImageDate,Photo,ImageName)VALUES(" + txtPatientId.Text + ",'" + txtImageDate.Value.ToString("yyyy/MM/dd HH:mm:ss") + "', @Photo ," + txtImageName.Text + ")";
OleDbParameter picParam = Com.Parameters.Add("@Photo", SqlDbType.Binary);
picParam.Value = picbyte.ToArray();
picParam.Size = picbyte.ToArray().Length;
Com.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
Con.Close();
MessageBox.Show("Image Uploaded Successfully", "PIS System");
}
}
推荐答案
这篇关于如何修复这个错误..'没有给出一个或多个必需参数的值'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!