using (SqlConnection con = new SqlConnection(connect.conn))
                    {
                        FileStream fs = new FileStream(connect.picpath,FileMode.Open,FileAccess.Read);
                        byte[] imagebytes = new byte[fs.Length];
                        BinaryReader br = new BinaryReader(fs);
                        imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));
                        con.Open();
                        SqlCommand com = new SqlCommand("insert into employees(photo) values(@image) where employeeID="+this.textBox6.Text,con);
                        SqlParameter image = new SqlParameter("@image",SqlDbType.Image);
                        image.Value = imagebytes;
                        com.Parameters.Add(image);
                        com.ExecuteNonQuery();
                    }提示WHERE附近有错误

解决方案 »

  1.   

    本帖最后由 net_lover 于 2012-03-27 15:33:53 编辑
      

  2.   

    本帖最后由 net_lover 于 2012-03-27 15:34:31 编辑
      

  3.   

    br.BaseStream.Position = 0;
      

  4.   

    把这个也搞成参数类型的吧  然后看看本身的sql语句是不是有错误了  注意全角/半角 和输入法的问题
      

  5.   


    FileStream fs = new FileStream(connect.picpath,FileMode.Open,FileAccess.Read);
                            byte[] imagebytes = new byte[fs.Length];
                            BinaryReader br = new BinaryReader(fs);
                            imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length));
                            con.Open();
                            SqlCommand com = new SqlCommand("insert into employees(photo) values(@image) where [email protected]",con);
                            com.Parameters.AddWithValue("@image", imagebytes);
                            com.Parameters.AddWithValue("@employeeID", this.textBox6.Text);
                            com.ExecuteNonQuery();还是where错误
      

  6.   


    谁告诉你这么写的???
    "insert into employees(photo) values(@image) where employeeID=@employeeID"
    不是
    "insert into employees(photo) values(@image) where [email protected]"
      

  7.   

    嗯  插入以前有这条数据没  有的话 直接update吧
      

  8.   

    employeeID不是数字要用''
    你是更新吧,你写成插入了