c# - MySQL .Net Connector Issue Executing Routine -


i'm having issue getting code execute mysql routine.

keeps popping error:

procedure or function 'shortenedurls' cannot found in database 'get'.

routine

delimiter $$  use `o7thurlshortner`$$  drop procedure if exists `get.shortenedurls`$$  create definer=`root`@`localhost` procedure `get.shortenedurls`(in `id` bigint)     no sql select `shortid`, `shortcode`, `url`, `clickthroughs` `shortener` `accountid` = id$$  delimiter ; 

code - accessing , running routine

    internal dbdatareader getresults()     {         try         {             // check parameters             if (areparams())             {                 prepareparams(_cmd);             }             // set our connection             _cmd.connection = _conn;             // set type of query run             _cmd.commandtype = _qt;             // set actual query run             _cmd.commandtext = _qry;             // open connection             _cmd.connection.open();             // prepare command parameters may have gotten added             _cmd.prepare();             // execute sqldatareader, , set connection close once returned             _rdr = _cmd.executereader(commandbehavior.closeconnection);             // clear out parameters             _cmd.parameters.clear();             // return our reader object             return (!_rdr.hasrows) ? null : _rdr;         }         catch (dbexception sqlex)         {             _msg += "acccess.getresults sqlexception: " + sqlex.message;             errorreporting.writeem.writeitem(sqlex, "o7th.class.library.data.mysql.access.getresults", _msg);             return null;         }         catch (exception ex)         {             _msg += "acccess.getresults exception: " + ex.message;             errorreporting.writeem.writeitem(ex, "o7th.class.library.data.mysql.access.getresults", _msg);             return null;         }     } 

code - fire off

        ilist<typing> _t = wrapper.getresults<typing>("get.shortenedurls",             system.data.commandtype.storedprocedure,             new string[] { "?id" },             new object[] { 1 },             new mysqldbtype[] { mysqldbtype.int32 },             false); 

update

verified work once fireoff routine without . in it.

how can work if routines have .'s, cannot re-write existing procedures in production database tied high traffic website...

in order call stored procedure have wrap name of in backticks since contains special character .

however, there bug in mysql connector code causing escape again. when specify

cmd.commandtype = commandtype.storedprocedure; 

the code branches during execute reader can see below...

if (statement == null || !statement.isprepared) {   if (commandtype == commandtype.storedprocedure)     statement = new storedprocedure(this, sql);   else     statement = new preparablestatement(this, sql); }  // stored procs statement type need during resolve statement.resolve(false); // problem occurs here 

part of resolve fix procedure name..

//storedprocedure.cs line 104-112 private string fixprocedurename(string name) {     string[] parts = name.split('.');     (int = 0; < parts.length; i++)         if (!parts[i].startswith("`", stringcomparison.ordinal))             parts[i] = string.format("`{0}`", parts[i]);     if (parts.length == 1) return parts[0];     return string.format("{0}.{1}", parts[0], parts[1]); } 

as can see here, anytime stored procedure name has . in it, name of stored procedure broken parts , escaped individually, , causing code not able call stored procedure.

so options fix are..

1) open bug oracle fix provider (assuming there not 1 open)
2) change name of stored procedure not use .
3) download code provider, fix it, recompile
4) find connector


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -