This is a discussion on don't no why?, Stored procedure, Very simple! within the MySQL Database forums, part of the Database Forums category; Reference : C# + Asp.net ; ODBC ; Mysql 5.0 ; WindowsXP Pro //<------------ C# source ////////////////////////////////////////////////////// using System; using System.Data; using System....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Reference : C# + Asp.net ; ODBC ; Mysql 5.0 ; WindowsXP Pro
//<------------ C# source ////////////////////////////////////////////////////// using System; using System.Data; using System.Data.Odbc; namespace ConnectionEx { /// <summary> /// Class1¿¡ ´ëÇÑ ¿ä¾à ¼³¸íÀÔ´Ï´Ù. /// </summary> class Class1 { /// <summary> /// ÇØ´ç ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ÁÖ ÁøÀÔÁ¡ÀÔ´Ï´Ù. /// </summary> [STAThread] static void Main(string[] args) { OdbcConnection objConn; objConn = new OdbcConnection(); string connectionString = "Driver={MySQL Connector/ODBC v5};" + "SRVR=address;" + "Dbq=dsn_address;" + "Uid=root;" + "Pwd=;"; objConn.ConnectionString = connectionString; OdbcCommand command = new OdbcCommand(); command.Connection = objConn; command.CommandType = CommandType.StoredProcedure; command.CommandText = "HelloWorld"; command.Connection.Open(); command.ExecuteNonQuery(); //--> occur error } } } //------------> C# source ////////////////////////////////////////////////////// ################# C# result (Error) #############################// --> 󸮵ÇÁö ¾ÊÀº ¿¹¿Ü : System.Data.Odbc.OdbcException : ERROR [HY000] [MySQL][MyODBC 5.00.10] [MySQL} 1064 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 'HelloWorld' at line 1 at System.Data.Odbc.OdbcConnection.HandleError(Handle Ref hrHandle, WQL_HANDLE hType, RETCODE retcode) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(C ommandBehavior behavior,String method) at System.Data.Odbc.OdbcCommand.ExecuteNonQuery() at ConnectionEx.Class1.InsertDataWithSp(OdbcConnectio n connection) in d:...... Line167 at ConnectionEx.Class1.Main(String[] args) in d:\\ Line 85 Press any key to continue ################################################## ######## //<------------------------------------Stored Procedure source " HelloWorld" CREATE PROCEDURE `HelloWorld`() NOT DETERMINISTIC SQL SECURITY DEFINER COMMENT '' BEGIN SELECT "HelloWorld"; END; //------------------------------------> Stored Procedure source // <------------------ result run sp "hello world" mysql> use address Database changed mysql> CREATE PROCEDURE `HelloWorld`() -> NOT DETERMINISTIC -> SQL SECURITY DEFINER -> COMMENT '' -> BEGIN -> SELECT ""; -> END; -> // ERROR 1304 (42000):PROCEDURE HelloWorld already exists // no problem mysql> // ------------------> result run sp "hello world" |
|
|||
|
try : command.CommandText = "call HelloWorld()";
On 29 jan, 08:10, "Hongs" <gome...@hanmail.net> wrote: > Reference : C# + Asp.net ; ODBC ; Mysql 5.0 ; WindowsXP Pro > > //<------------ C# source > ////////////////////////////////////////////////////// > using System; > > using System.Data; > using System.Data.Odbc; > > namespace ConnectionEx > { > /// <summary> > /// Class1¿¡ ´ëÇÑ ¿ä¾à ¼³¸íÀÔ´Ï´Ù. > /// </summary> > class Class1 > { > /// <summary> > /// ÇØ´ç ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ÁÖ ÁøÀÔÁ¡ÀÔ´Ï´Ù. > /// </summary> > [STAThread] > static void Main(string[] args) > { > OdbcConnection objConn; > objConn = new OdbcConnection(); > > string connectionString = "Driver={MySQL Connector/ODBC v5};" + > "SRVR=address;" + > "Dbq=dsn_address;" + > "Uid=root;" + > "Pwd=;"; > > objConn.ConnectionString = connectionString; > > OdbcCommand command = new OdbcCommand(); > command.Connection = objConn; > > command.CommandType = CommandType.StoredProcedure; > command.CommandText = "HelloWorld"; > > command.Connection.Open(); > command.ExecuteNonQuery(); //--> occur error > } > > }}//------------> C# source > ////////////////////////////////////////////////////// > > ################# C# result (Error) #############################// --> > 󸮵ÇÁö ¾ÊÀº ¿¹¿Ü : System.Data.Odbc.OdbcException : ERROR [HY000] > [MySQL][MyODBC 5.00.10] > > [MySQL} 1064 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 'HelloWorld' at line 1 > > at System.Data.Odbc.OdbcConnection.HandleError(Handle Ref hrHandle, > WQL_HANDLE hType, RETCODE > > retcode) > > at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(C ommandBehavior > behavior,String method) > > at System.Data.Odbc.OdbcCommand.ExecuteNonQuery() > > at ConnectionEx.Class1.InsertDataWithSp(OdbcConnectio n connection) in > d:...... Line167 > > at ConnectionEx.Class1.Main(String[] args) in d:\\ Line 85 > > Press any key to continue > > ################################################## ######## > > //<------------------------------------StoredProceduresource " HelloWorld" > > CREATEPROCEDURE`HelloWorld`() > > NOT DETERMINISTIC > > SQL SECURITY DEFINER > > COMMENT '' > > BEGIN > > SELECT "HelloWorld"; > > END; > > //------------------------------------> StoredProceduresource > > // <------------------ result run sp "hello world" > mysql> use address > > Database changed > > mysql> CREATEPROCEDURE`HelloWorld`() > > -> NOT DETERMINISTIC > > -> SQL SECURITY DEFINER > > -> COMMENT '' > > -> BEGIN > > -> SELECT ""; > > -> END; > > -> // > > ERROR 1304 (42000):PROCEDUREHelloWorld already exists // no problem > mysql> > > // ------------------> result run sp "hello world" |