Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8333639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:06:05+00:00 2026-06-09T03:06:05+00:00

I’m a total newb to stored procedures, so I may be missing something easy,

  • 0

I’m a total newb to stored procedures, so I may be missing something easy, but I researched the basics and I’m stuck trying to integrate it from vb.net code. I created a simple stored procedure (I think) that just runs a query of data for today’s results:


— Routine DDL
— Note: comments before and after the routine body will not be stored by the server


DELIMITER $$

CREATE DEFINER=`root`@`%` PROCEDURE `GetRuntestToday`()
BEGIN

Select * From runtest.runtest_records where
Test_Date=CURDATE()
order by test_date desc, Convert(test_time_stop,DECIMAL(5,2)) desc;

END

When I log on to the main MySql database and attempt to run it from the MySql prompt, it appears to work fine. I simply type call runtest.GetRuntestToday(); and it returns 59 rows of data in command prompt text form.

I wrote a VB.net program to try to get that same data but I keep getting an error. The error exception details are:

System.Data.Odbc.OdbcException was unhandled
  ErrorCode=-2146232009
  Message="ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.1.51-community-log]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 'GetRuntestToday' at line 1"
  Source="myodbc5.dll"
  StackTrace:
       at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
       at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
       at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
       at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
       at System.Data.Odbc.OdbcCommand.ExecuteReader()
       at MySqlHelper.mMain.DoMyStoredProcedure() in C:\vss\MySqlHelper\MySqlHelper\mMain.vb:line 2642
       at MySqlHelper.mMain.Main() in C:\vss\MySqlHelper\MySqlHelper\mMain.vb:line 29
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

The code I am running is:

Public Sub DoMyStoredProcedure()

    Dim MyConString As String = "My String Details"
    Dim dbcRuntest As New OdbcConnection(MyConString)


    Dim cmd As New OdbcCommand
    Dim reader As OdbcDataReader

    cmd.CommandText = "GetRuntestToday"
    cmd.CommandType = CommandType.StoredProcedure
    cmd.Connection = dbcRuntest

    dbcRuntest.Open()

    reader = cmd.ExecuteReader()

    dbcRuntest.Close()
End Sub

The error happens on the line:

reader = cmd.ExecuteReader()

What am I missing? I don’t see any syntax problems and the stored procedure works from the command prompt. I’ve played around a little with the DELIMITER stuff making it // instead of $$ but nothing seems to fix it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:06:06+00:00Added an answer on June 9, 2026 at 3:06 am

    You might try changing to a direct call (I haven’t tested this:

     cmd.CommandType = CommandType.Text
     cmd.CommandText = "CALL GetRuntestToday"
    

    Also, a better way of writing your code:

    Dim MyConString As String = "My String Details"
    Using dbcRuntest As New OdbcConnection(MyConString)
      dbcRuntest.Open()
      Using cmd As New OdbcCommand("CALL GetRuntestToday", dbcRuntest)
        cmd.CommandType = CommandType.Text
        Using reader As OdbcDataReader = cmd.ExecuteReader
          'do someting with reader'
        End Using
      End Using 
    End Using
    

    The Using structure automatically closes the connection and disposes it (along with the other objects).

    Edited to use CALL instead of EXECUTE

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.