c#存文件入库找不到存储过程
错误提示:找不到存储过程"ImageUpdate"源码如下:
using System;
using
using System.Data.SqlClient;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestIO
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open);
int imgLen = (int)fs.Length;
byte[] imgBinaryData = new byte[imgLen];
int nBytesRead = fs.Read(imgBinaryData, 0, imgLen);
string strConn = "Data Source=MS-201205202003\\SQLEXPRESS;";
strConn += "Initial Catalog=Northwind;";
strConn += "User ID=sa;";
strConn +="Password=1989117;";
SqlConnection Conn = new SqlConnection(strConn);
try
{
SqlCommand oCmd = new SqlCommand("ImageUpdate", Conn);
= CommandType.StoredProcedure;
oCmd.Parameters.Add("@CategoryID",SqlDbType.Int).Value = 5;
oCmd.Parameters.Add("@imageData", SqlDbType.Image).Value = imgBinaryData;
oCmd.Connection.Open();
oCmd.ExecuteNonQuery();
oCmd.Connection.Close();
MessageBox.Show("图像数据已经存入数据库");
}
catch(Exception oExcept)
{
MessageBox.Show(oExcept.Message);
}
fs.Close();
}
}
}
}