don't no why?, Stored procedure, Very simple!

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....


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-29-2007
Hongs
 
Posts: n/a
Default don't no why?, Stored procedure, Very simple!

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"


Reply With Quote
  #2 (permalink)  
Old 01-30-2007
Olivier
 
Posts: n/a
Default Re: don't no why?, Stored procedure, Very simple!

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"


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:26 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0