Asp.net文件上传到Oracle错误 [英] Asp.net fileUpload to Oracle Error

查看:73
本文介绍了Asp.net文件上传到Oracle错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好;

我需要有关文件上传的帮助;
保存Oracle数据库后,我将获取一个文件;
我的oracle db类型;

hello;

I need help about file upload;
I will take a file after save the Oracle db;
My oracle db type ;

FILEID			INTEGER		
MACHINENAME	        VARCHAR2 (30 Byte)		
DOSYATYPE		VARCHAR2 (30 Byte)		
DOSYA	 	        BLOB		
ICERIK	        	VARCHAR2 (100 Byte)		
YUKLEME_TARIH		DATE		
ONCEKI_DOSYA_ID		INTEGER


并在代码中

并且在Codebihend


and in code

and in Codebihend

string filePath =fulDoc.PostedFile.FileName;
            string filename = Path.GetFileName(filePath);
            string ext = Path.GetExtension(filename);
            string contenttype = String.Empty;
            //dosya uzantılarını tanımlıyoruz.
            switch (ext)
            {
                case ".doc":
                    contenttype = "application/vnd.ms-word";
                    break;
                case ".docx":
                    contenttype = "application/vnd.ms-word";
                    break;
                case ".xls":
                    contenttype = "application/vnd.ms-excel";
                    break;
                case ".xlsx":
                    contenttype = "application/vnd.ms-excel";
                    break;
                case ".jpg":
                    contenttype = "image/jpg";
                    break;
                case ".png":
                    contenttype = "image/png";
                    break;
                case ".gif":
                    contenttype = "image/gif";
                    break;
                case ".pdf":
                    contenttype = "application/pdf";
                    break;
            }
          
            if (fulDoc.PostedFile != null && fulDoc.PostedFile.FileName != "")
            {
                Stream fs = fulDoc.PostedFile.InputStream;
                BinaryReader br = new BinaryReader(fs);
                Byte[] bytes = br.ReadBytes((Int32)fs.Length);

                docquery="INSERT INTO DOCUMENTS "+
                    "( FILEID , MACHINENAME ,"+
                "DOSYATYPE , DOSYA ,"+
                "ICERIK , YUKLEME_TARIH ,"+
                "ONCEKI_DOSYA_ID )VALUES("+
                "1, '"+machinename+"', '"+docname+"' , "+
                "'" + bytes + "' , '" + doccontent + "' , " +
                 "'"+DateTime.Today+"' , '0')";
                SQLQueries sq = new SQLQueries(docquery);
                sq.CreateConnection();
                sq.DataInsert();
                sq.CloseConnection();
            }



在SQLQueries,有我的连接代码.当我运行查询时;



at SQLQueries there is my connection code. When I run the query is;

INSERT INTO DOCUMENTS ( FILEID , MACHINENAME ,DOSYATYPE , DOSYA ,ICERIK , YUKLEME_TARIH ,ONCEKI_DOSYA_ID )VALUES(1, 'xxxx', '' , 'System.Byte[]' , '' , '23.08.2012' , '0')


但这是行不通的:(

请帮助:)


but it isn''t work :(

Please Help :)

推荐答案

ORA-01465:geçersizonaltılısayı(错误的十六进制数字)
ORA-01465: geçersiz onaltılı sayı( wrong hexadecimal number)


更新错误或在其他描述问题的信息中,第一件事是永远不要将值直接连接到SQL语句.这使您可以进行SQL注入,数据类型不匹配,转换问题等等.

始终使用适当的参数类为语句定义适当的参数.根据您使用的技术,例如,请参考:
- OracleParameter [ OleDbParameter [
While you update the error or other information describing the problem, the first thing is that you should never concatenate values directly to your SQL statement. This leaves you open to SQL injections, data type mismatches, conversion problems and so on.

Always use proper parameter class to define proper parameters for a statement. Depending on the technology you use, refer for example to:
- OracleParameter[^]
- OleDbParameter[^]

Update:

Based on the error, you probably are facing data type conversion problems. So properly utilizing a parameter would resolve the situation (for the blob field in this case).


这篇关于Asp.net文件上传到Oracle错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆