c# - ORA-01722: invalid number #2 -


the error had before can't insert null value resources_id added resources_id insert value avoid issue, when error:

ora-01722: invalid number c#

line 56: cmd.executenonquery();.

what did before avoid issue removed not null , left null in table , works caused me other troubles found hard solve, decided go main issue , added not null resources_id in database. please solve issue.

another issue have resources_id in parameters not recognised

my code:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data.oracleclient; using system.configuration; using system.io;    public partial class lecturer_upload_resources : system.web.ui.page {     string strcon = "data source=****;persist security info=true;user id=****;password=****;unicode=false";     protected void page_load(object sender, eventargs e)     {         if (!ispostback)         {             bindgridviewdata();         }     }     // bind gridview data     private void bindgridviewdata()     {         using (oracleconnection con = new oracleconnection(strcon))         {             using (oraclecommand cmd = new oraclecommand())             {                 cmd.commandtext = "select * resource1";                 cmd.connection = con;                 con.open();                 gvdetails.datasource = cmd.executereader();                 gvdetails.databind();                 con.close();             }         }     }     // save files folder , files path in database     protected void btnupload_click(object sender, eventargs e)     {           string filename = path.getfilename(fileupload1.postedfile.filename);         stream str = fileupload1.postedfile.inputstream;         binaryreader br = new binaryreader(str);         byte[] size = br.readbytes((int)str.length);         using (oracleconnection con = new oracleconnection(strcon))         {             using (oraclecommand cmd = new oraclecommand())             {                 cmd.commandtext = "insert resource1(resources_id,filename,filetype,filedata) values(:resources_id,:filename,:filetype,:filedata)";                 cmd.parameters.addwithvalue(":resources_id",resources_id);                 cmd.parameters.addwithvalue(":filename", filename);                 cmd.parameters.addwithvalue(":filetype", "application/word");                 cmd.parameters.addwithvalue(":filedata", size);                 cmd.connection = con;                 con.open();                 cmd.executenonquery();                 con.close();                 bindgridviewdata();             }         }     } 

try use this

cmd.bindbyname = true; 

in insert block or try delete ":"


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -