Hi everyone,

 

 

This is my first project in MySql database. I use VB.Net and OleDb to connect 
to  MySql(5.0.1 alpha-max). When I call the stored produce, I get the error 
message:

 

ERROR [42000][MySQL][ODBC 3.51 Driver][mysqld-5.0.1-alpha-max]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 'usp_CountryAll' at line 1

 

 

 

When I call the same stored procedure in the MySql console, it is fine. But 
when I call it at the MySql Query Broswer, I get "SELECT in a stored procedure 
must have INTO" error message. I have checked it on the internet and I saw many 
messages about "SELECT in a stored procedure must have INTO" error message. But 
I didn't find the direct answer in my case. I am very appreciated, if anyone 
can point out how to change my source code in follows. 

 

 

 

Here is my stored procedure and VB.Net code:

 

 

 

CREATE PROCEDURE `testdb`.`usp_CountryAll`()

 

SELECT CountryId, ShortName, FullName FROM Country ORDER BY ShortName

 

 

 

 

 

        Try

 

            Dim oOdbcDA As OdbcDataAdapter = New OdbcDataAdapter

 

            Dim oOdbcCmd As OdbcCommand

 

            Dim oDS As DataSet = New DataSet

 

            Dim oRow As DataRow

 

            Dim oMySqlConn As OdbcConnection = New OdbcConnection

 

            oMySqlConn.ConnectionString = "DRIVER={MySQL ODBC 3.51 
Driver};SERVER=localhost;DATABASE=testdb;USER=root;PASSWORD=;OPTION=3"

 

            oMySqlConn.Open()

 

                oOdbcCmd = New OdbcCommand("usp_CountryAll", oMySqlConn)

 

            oOdbcCmd.CommandType = CommandType.StoredProcedure

 

            oOdbcDA.SelectCommand = oOdbcCmd

 

            oOdbcDA.Fill(oDS)

 

            For Each oRow In oDS.Tables(0).Rows

 

                lstResult.Items.Add(oRow("FullName"))

 

            Next

 

        Catch ex As Exception

 

            MsgBox(ex.Message)

 

        End Try

 

 

 

 

Thanks!

 

Owen Ni


                        
---------------------------------
Do you Yahoo!?
 Check out the new Yahoo! Front Page. www.yahoo.com

Reply via email to