TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vu Hong Trieu
NA
107
6.6k
MySql stored procedure not exist with C# .NET
Aug 11 2017 5:27 PM
I try connected MySql stored procedure from c# .Net via MySqlDataAdapter but when i fill data to datatable or dataset has error "Additional information: FUNCTION demo.loadtable does not exist".
My stored
DELIMITER $$
USE `demo`$$
DROP PROCEDURE IF EXISTS `loadtable`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `loadtable`()
BEGIN
SELECT * FROM tablesx;
END$$
DELIMITER ;
My code
1.
loadData
method
public
void
loadData(tables model)
{
connect();
ds=
new
DataSet();
MySqlParameter[] prams = {
MakeInParam(
"@id"
,MySqlDbType.Int32,4,model.id)
};
RunProcDS(
"loadtable"
, prams, out ds);
}
2.
RunProcDS
method
public
int
RunProcDS(string procName, MySqlParameter[] prams, out DataSet dataSet)
{
DataSet ds;
MySqlCommand cmd = CreateCommand(procName, prams);
MySqlDataAdapter dad =
new
MySqlDataAdapter(cmd);
MySqlCommandBuilder cb =
new
MySqlCommandBuilder(dad);
ds =
new
DataSet();
dad.Fill(ds,
"CurrentItems"
);
dataSet = ds;
this
.Close();
return
(
int
)cmd.Parameters[
"ReturnValue"
].Value;
}
Has error att line 08 " dad.Fill(ds,
"CurrentItems");
"
3.
CreateCommand
method
private
MySqlCommand CreateCommand(string procName, MySqlParameter[] prams)
{
Open();
MySqlCommand cmd =
new
MySqlCommand(procName, con);
if
(cmd.Parameters.Count > 0)
{
cmd.Parameters.Clear();
}
cmd.CommandType = CommandType.StoredProcedure;
if
(prams != null)
{
foreach (MySqlParameter parameter in prams)
cmd.Parameters.Add(parameter);
}
cmd.Parameters.Add(
new
MySqlParameter(
"ReturnValue"
, MySqlDbType.Int32, 4,
ParameterDirection.ReturnValue,
false
, 0, 0,
string.Empty, DataRowVersion.Default, null));
return
cmd;
}
Please help.
Thanks,
Reply
Answers (
3
)
How can i get network usage per process
Tab index position color