Solved

STORED PROC not returning IN ASP.NET

Posted on 2014-10-03
5
51 Views
Last Modified: 2016-06-14
Not sure if this is a DB or a programming issue.  I have a stored proc in MySQL 5.2 that runs in the console as expected.  however, when I call it in my app, I get an empty dataset.  the code I use to call it is a custom class that handles all my DB input/output.  I don't believe that is the issue (as it works and has been working for 2 years on many places).  


STORED PROC:
CREATE DEFINER = `admin`@`localhost` PROCEDURE `NewProc`(IN _InvoiceNo varchar(7), IN _SalespersonCode varchar(4))
BEGIN
IF (_SalespersonCode ="admn") THEN
	Select * from invoiceheader where InvoiceNumber LIKE concat(_InvoiceNo , "%") ORDER BY InvoiceDate desc LIMIT 100; 
ELSE
	Select * from invoiceheader where InvoiceNumber LIKE concat(_InvoiceNo , "%") and SalesPersonCode =_SalespersonCode ORDER BY InvoiceDate desc LIMIT 100;
END IF;
END;

Open in new window


Call from app:
 public void Fill(String UserName, String InvNo)
    {
        user usr = new user();
        usr.GetUserByUsername(UserName, _AccessKey);
        _DA.PrameterSet.Add("_InvoiceNo", InvNo);
        if (usr.UserType == 3 || usr.UserType == 5 || usr.UserType == 7)
        {
            _DA.PrameterSet.Add("_SalespersonCode", usr.SalesPersonCode);
        }
        else
        {
            _DA.PrameterSet.Add("_SalespersonCode", "admn");
        }
        _DS = _DA.GetDataset("getInvoiceHeaderByInvoiceNoPartial");

Open in new window


_DA is my custom data Access class that I regularly use.  the GetDataset method's only requirement for the Proc, it that returns a dataset.  I've stepped through the code, and nothing errors.  I have verified the parameters sent match those that I used directly on the DB.  just wondering  if there is something I'm not seeing.
0
Comment
Question by:Jfb1126
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 25

Expert Comment

by:Tomas Helgi Johannsson
ID: 40361117
Hi!

Using the ASP.net are you calling the SP from another host than your console execution ?
If so then I would look at the users and SP security. That is what has been granted to the
user executing the SP from the ASP.net.

http://dev.mysql.com/doc/mysql-security-excerpt/5.1/en/adding-users.html

Execute this command in the Mysql console

SHOW GRANTS FOR 'user@host';

Open in new window


where user is the user you use in the ASP code and host is the IP address or hostname of the host executing the ASP code.

It may be that the user has execution rights on the SP but not select rights on the table.

Also I noticed that the SP has not an OUT parameter just IN. That could also be the case.
http://dev.mysql.com/doc/refman/5.1/en/stored-programs-views.html
http://dev.mysql.com/doc/refman/5.1/en/stored-routines-syntax.html
http://dev.mysql.com/doc/connector-net/en/connector-net-tutorials-stored-procedures.html


Regards,
     Tomas Helgi
0
 

Author Comment

by:Jfb1126
ID: 40363819
thanks for the reply...  the user has full rights to the database.   the SHOW GRANTS is as follows:

mysql> show grants for 'edelivery'@'localhost';
+------------------------------------------------------------------------------------------------------------------+
| Grants for edelivery@localhost                                                                                   |
+------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'edelivery'@'localhost' IDENTIFIED BY PASSWORD 'XXXXXXX' |
| GRANT ALL PRIVILEGES ON `edelivery`.* TO 'edelivery'@'localhost'                                                 |
| GRANT SELECT ON `edelivery`.`resourcerights` TO 'edelivery'@'localhost'                                          |
| GRANT SELECT ON `mysql`.`proc` TO 'edelivery'@'localhost'                                                        |
+------------------------------------------------------------------------------------------------------------------+
4 rows in set

mysql> 

Open in new window


also changed the definer to the executing user.  I have many SP that do not have an out and returns a dataset.  this SP was a new one, but I just realized I am having the same issue with another SP that has been working for years.  

I did fail to mention that I moved the entire site & DB (everything appeared to be working) so I think you may be right that it is some security issue I haven't noticed.
0
 

Author Comment

by:Jfb1126
ID: 40364449
OK, I am thoroughly confused....  I am going to walk through everything I did and hopefully something will stick out.  
Site and DB runs are same machine in all instances

was  running fine on old server (windows server 2008; mySQL 5.1.56)  
have/had working test platform (windows7; mySQL 5.2.3)
moved to new server  (windows server 2012; mySQL 5.1.73)  

-transferred DB from old server to both the new server and test platform.
-verified user has full DB rights.
-set user as definer for all SP.
-installed MySQL connector 5.6 (this was the cause of some existing SP not working)
          [side note here, I find it interesting that the error was "function XXX does not exist".  as if it was looking for a function instead of a stored procedure.]
-removed MySQL connector 5.6
-installed MySQL connector 5.0.6 (existing SP now work).
so back to the issues with the new SP
-SP returns data in console with both the user and the root user
-SP still does not return data via the connector with user or root user.
-same results on both new server and test platform.
0
 

Accepted Solution

by:
Jfb1126 earned 0 total points
ID: 40370897
fixed... dumb error...  was not adding the dataset to the collection.  what was confusing me, was when I stepped through the code, the dataset said the record count was zero.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question