C# code problem
-
I have a button in my form and on click of that button I am writing this code.... OdbcCommand cmd ; cmd = new OdbcCommand(abc, cn); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); I have made a procedure named abc in database which is returning only one row from login table..So i am just checking that on click of that button my procedure should run but while debugging when i come to cmd.ExecuteQuery() it throws following error.. ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.77-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abc()' at line 1. So plz tell me what would be the problem..
-
I have a button in my form and on click of that button I am writing this code.... OdbcCommand cmd ; cmd = new OdbcCommand(abc, cn); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); I have made a procedure named abc in database which is returning only one row from login table..So i am just checking that on click of that button my procedure should run but while debugging when i come to cmd.ExecuteQuery() it throws following error.. ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.77-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abc()' at line 1. So plz tell me what would be the problem..
Please stop spamming the forums with this same question[^]. You have been given suggestions about resolving this, go and try some of them.
-
Please stop spamming the forums with this same question[^]. You have been given suggestions about resolving this, go and try some of them.
-
Sir I have tried all the suggestions...and as u said i have posted in mysql but there was no reply..so i posted here...
nitish_07 wrote:
i have posted in mysql but there was no reply
Then you need to be more patient, and also read http://www.codeproject.com/Messages/3137519/Forum-Guidelines-PLEASE-READ.aspx[^].
-
I have a button in my form and on click of that button I am writing this code.... OdbcCommand cmd ; cmd = new OdbcCommand(abc, cn); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); I have made a procedure named abc in database which is returning only one row from login table..So i am just checking that on click of that button my procedure should run but while debugging when i come to cmd.ExecuteQuery() it throws following error.. ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.77-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'abc()' at line 1. So plz tell me what would be the problem..
nitish_07 wrote:
cmd = new OdbcCommand(abc, cn);
Your problem is that you did not read the error message, nor the manual that the error is referring to.
using (cmd = cn.CreateCommand())
{
cmd.CommandText = "EXEC abc()";
cmd.ExecuteNonQuery(); // this means that there'll be no results
}I don't want to see this question coming back :)
Bastard Programmer from Hell :suss:
-
nitish_07 wrote:
cmd = new OdbcCommand(abc, cn);
Your problem is that you did not read the error message, nor the manual that the error is referring to.
using (cmd = cn.CreateCommand())
{
cmd.CommandText = "EXEC abc()";
cmd.ExecuteNonQuery(); // this means that there'll be no results
}I don't want to see this question coming back :)
Bastard Programmer from Hell :suss:
Good eye! :thumbsup:
The difficult we do right away... ...the impossible takes slightly longer.
-
nitish_07 wrote:
cmd = new OdbcCommand(abc, cn);
Your problem is that you did not read the error message, nor the manual that the error is referring to.
using (cmd = cn.CreateCommand())
{
cmd.CommandText = "EXEC abc()";
cmd.ExecuteNonQuery(); // this means that there'll be no results
}I don't want to see this question coming back :)
Bastard Programmer from Hell :suss:
There is another faux pas OP committed. Not reading the MSDN documentation on EXEC / EXECUTE diligently:
[ { EXEC | EXECUTE } ]
{
[ @return_status = ]
{ module_name [ ;number ] | @module_name_var }
[ [ @parameter = ] { value
| @variable [ OUTPUT ]
| [ DEFAULT ]
}
]
[ ,...n ]
[ WITH [ ,...n ] ]
}
[;]Execute a character string
{ EXEC | EXECUTE }
( { @string_variable | [ N ]'tsql_string' } [ + ...n ] )
[ AS { LOGIN | USER } = ' name ' ]
[;]Execute a pass-through command against a linked server
{ EXEC | EXECUTE }
( { @string_variable | [ N ] 'command_string [ ? ]' } [ + ...n ]
[ { , { value | @variable [ OUTPUT ] } } [ ...n ] ]
)
[ AS { LOGIN | USER } = ' name ' ]
[ AT linked_server_name ]
[;]Parenthesis () are only allowed when executing indirectly via a string variable or string literal. Regards, Manfred
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
Me, 2012-05-24
-
nitish_07 wrote:
cmd = new OdbcCommand(abc, cn);
Your problem is that you did not read the error message, nor the manual that the error is referring to.
using (cmd = cn.CreateCommand())
{
cmd.CommandText = "EXEC abc()";
cmd.ExecuteNonQuery(); // this means that there'll be no results
}I don't want to see this question coming back :)
Bastard Programmer from Hell :suss:
I pointed this out to him in his original post.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier