Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
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

and in code

and in Codebihend

C#
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();
            }


at SQLQueries there is my connection code. When I run the query is;
SQL
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 :)
Posted
Updated 23-Aug-12 4:51am
v2
Comments
Wendelius 23-Aug-12 10:52am    
So what errror do you get?

ORA-01465: geçersiz onaltılı sayı( wrong hexadecimal number)
 
Share this answer
 
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).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900