C# File upload to sql database will not work -


i creating page adds product sql table. have seen , modified snippet of code need.

    string contenttype = imageupld.postedfile.contenttype;     using (stream fs = imageupld.postedfile.inputstream)     {         using (binaryreader br = new binaryreader(fs))         {             byte[] bytes = br.readbytes((int32)fs.length);             sqlconnection conn = new sqlconnection(webconfigurationmanager.connectionstrings["connectionstring"].connectionstring);             sqlcommand cmd = new sqlcommand("insert products (name, image, price, desc, author, preview, contenttype ) values ('" + nametxt.text + "', '" + bytes + "', '" + pricetxt.text + "', '" + desctxt.text + "', '" + session["username"] + "', '" + previewtxt.text + "')", conn);             cmd.commandtype = commandtype.text;             using (conn)             {                 conn.open();                 sqldatareader rdr = cmd.executereader();                 conn.close();             }         }     } 

visual studio highlights cmd.executereader(); says:

an exception of type 'system.data.sqlclient.sqlexception' occurred in system.data.dll not handled in user code

additional information: incorrect syntax near keyword 'desc'.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -