Click here to Skip to main content
15,907,395 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Here Is my c# code to access Procedure
C#
private void button1_Click(object sender, EventArgs e)
        {
            MySqlConnection con = new MySqlConnection(StrCon);
            MySqlCommand cmd = new MySqlCommand();
            MySqlDataReader dr;
            cmd.CommandText = "Taxes";**Error::Procedure or function '`Taxes`' cannot be found in database ''
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = con;

            con.Open();
            dr = cmd.ExecuteReader();
            dr.read()
            MessageBox.Show(dr[0].ToString());//Only for checking ID
            con.Close();
        }

And here is the procedure
SQL
Create Procedure Taxes()
Begin
   Select ID from Tax;
End

But when i click on button i am not able to access that procedure
* Show the actual error i got.
Is there any silly mistake in my code.Please Let me know.

thanks
Swapnil
Posted
Updated 5-Apr-12 11:03am
v4

//try to use this

SQL
create proc taxes
as
begin
select ID from Tax;
end
 
Share this answer
 
v4
Comments
swapnilKumbhar 4-Apr-12 1:59am    
It shows an error.When i removed it.
[no name] 4-Apr-12 2:04am    
use above code whn u create procedure an let me know
Hi,

As your code shows it should work properly.

If it's not then;
You need to check the database first where you have executed your stored procedure,

And then check; to which database you have made connectivity of your application.
 
Share this answer
 
Comments
swapnilKumbhar 4-Apr-12 2:16am    
hey thanks for replying.But i solved the problem.
But the actual problem with connection.Am not able to access DataBase from server
till i didn't off firewall.

Why this happens.
AmitGajjar 4-Apr-12 2:25am    
instead turn of your firewall, Add an exception for Database access for firewall
use the name like this dbo.taxes to create the sp
 
Share this answer
 

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