我的Oracle表的结构为:
create table Pic_info(
   PicDate   date not null,         //图片日期
   Unit      varchar2(40) not null, //单位
   Class     varchar2(16) not null, //图片类型
   PicName   varchar2(30) not null, //图片名称
   Pic       blob not null,         //图片
   yielder   varchar2(30) not null, //提供者
   yieldDate date not null,         //提供日期
   other     varchar2(100)          //其他备注信息
);提交按钮的事件驱动代码如下:
private void Button2_Click(object sender, System.EventArgs e)
{
   HttpPostedFile UpFile=UpPhoto.PostedFile;
   FileLength = UpFile.ContentLength;
   try 
   {
      if (FileLength == 0){
Response.Write("<script>alert('请选择上传的图片!')</script>");
      } 
      else {//获得图象并把图象转换为byte[]
HttpPostedFile upPhoto=UpPhoto.PostedFile;
int upPhotoLength=upPhoto.ContentLength;
byte[] PhotoArray=new Byte[upPhotoLength];
Stream PhotoStream=upPhoto.InputStream;
PhotoStream.Read(PhotoArray,0,upPhotoLength); string strSql="Insert into Pic_info (PicDate,Unit,Class,PicName,Pic,yielder,yieldDate,other) values(@PicDate,@Unit,@Class,@PicName,@Pic,@yielder,@yieldDate,@other)";
OracleCommand cmd=new OracleCommand(strSql,oracleConnection1);
cmd.Parameters.Add("@PicDate",OracleType.DateTime).Value=Convert.ToDateTime(TextBox1.Text).ToString("yyyy-MM-dd");
cmd.Parameters.Add("@Unit",OracleType.VarChar,40).Value=TextBox2.Text;
cmd.Parameters.Add("@Class",OracleType.VarChar,16).Value=DropDownList1.SelectedItem.Text.ToString();
cmd.Parameters.Add("@PicName",OracleType.VarChar,30).Value=TextBox3.Text;
cmd.Parameters.Add("@Pic",OracleType.Blob).Value=PhotoArray;
cmd.Parameters.Add("@yielder",OracleType.VarChar,30).Value=TextBox5.Text;
cmd.Parameters.Add("@yieldDate",OracleType.DateTime).Value=Convert.ToDateTime(TextBox6.Text).ToString("yyyy-MM-dd");
cmd.Parameters.Add("@other",OracleType.VarChar,100).Value=TextBox7.Text;
oracleConnection1.Open();
cmd.ExecuteNonQuery();
oracleConnection1.Close();
Response.Write("<script>alert('图片上传成功!')</script>");
      }
   } 
   catch (System.Exception ex){
Response.Write(ex.Message.ToString());
   }
}
在各个输入控件中输入相应的数据并提交后出现《ORA-01036: 非法的变量名/编号》的异常信息,这到底是那里的问题?该怎么解决?(我是新手,希望能详细点最好)万分感谢各位高手的指点!

解决方案 »

  1.   

    http://blog.csdn.net/gaofeng2000/archive/2004/08/27/86264.aspx
      

  2.   

    cmd.Parameters.Add("@Pic",OracleType.Blob).Value=PhotoArray;
    这句不对应该这么写
    cmd.Parameters.Add("@Pic",OracleType.Binary, size(上传文件的大小)).Value=PhotoArray;
      

  3.   

    OracleType 中没有 Binary 类型,有 BFile ,Blob ,Byte ,Char ,Clob,Cursor,DateTime,Double,Float,Int16,Int32,IntervalDayToSecond,IntervalYearToMonth,LongRaw,LongVarChar,NChar,NClob,Number,NVarChar,Raw,RowId,SByte,Timestamp,TimestampLocal,TimestampWithTZ,UInt16,UInt32,VarChar 等类型。
      

  4.   

    改写为 cmd.Parameters.Add("@Pic",OracleType.Byte,upPhotoLength).Value=PhotoArray; 后出现《对象必须实现 IConvertible》的异常信息。系统是不是将Byte转换成Blob没有实现?在创建表时Pic字段的类型为Blob型,在内存数据集dataSet1里的Pic_info内存表中pic字段的原先类型是base64Binary,我把它改成Byte型了,不管用那一种类型都有异常信息出现,请高手指下解决问题的办法。
      

  5.   

    哈哈,没看清楚是Oracle的连接,我一般不用这个,用OleDb的多。
      

  6.   

    今天表结构改了,将 Pic 字段类型改为 LongRaw (以前是Blob型),并将以前在web窗体上添加的oOracleConnection,oracleDataAdapter,DataSet 以及《解决方案资源管理器》中的DataSet.xsd 全都删了,然后重新添加了如上所说的数据库操纵控件。在DataSet.xsd里的内存表表Pic_info中的pic字段类型怎么又是 base64Binary ?是不是因为这个东西才出现类型不匹配的问题呀?改写为 cmd.Parameters.Add("@Pic",OracleType.LongRaw,upPhotoLength).Value=PhotoArray;后又出现《ORA-01036: 非法的变量名/编号》的异常信息,这该怎么办?(嘿...感觉很累啊)