标题:c#存文件入库找不到存储过程
只看楼主
眼圈黑黑
Rank: 2
等 级:论坛游民
帖 子:27
专家分:20
注 册:2010-4-7
结帖率:60%
 问题点数:0 回复次数:0 
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();
            }
        }
    }
}
搜索更多相关主题的帖子: 存储 void private public 
2012-07-10 20:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-373120-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.111782 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved