During calling procedure from c# it showing the following Error
"Procedure or function 'CALL
get_Users()'
cannot be foundin database '
joomla
'."`
the code is as follows
public ObservableCollection<Users> loadUserData()
{
ObservableCollection<Users> UserDetials = new ObservableCollection<Users>();
Users users;
using (MySqlConnection Conn = new MySqlConnection(DataBaseConnection))
{
Conn.Open();
MySqlCommand command = new MySqlCommand("CALL `get_Users();", Conn); // uasing this one it showing Error
// MySqlCommand command = new MySqlCommand("select * from users", Conn); -- if this code run it's taking data from the database
command.CommandType = System.Data.CommandType.StoredProcedure;
using (var cursor = command.ExecuteReader())
{
while (cursor.Read())
{
users = new Users();
users.UserId = Convert.ToInt64(Reader["id"]);
users.UserName = Convert.ToString(Reader["Name"]);
UserDetials.Add(users);
}
}
}
return UserDetials;
}
Please correct me if I'm wrong, but I think you can call your stored procedure without the CALL keyword and (). Since, you already shoot the command on System.Data.CommandType.StoredProcedure
.
So you might try MySqlCommand("get_Users", Conn)