MySql.Data.MySqlClient.MySqlException: Table 'someTable' doesn't exist - but it does

Posted on 2006-05-31
Last Modified: 2008-02-01
I have a program that that wants to query a MySql DB to get information. It seems to connect but I get the error in the title
which says the table does not exist. Any suggestions on why this is happening and how to get around it? Below is the code and error.
Thanks in advance. Joe

Dim oString As String
Dim intNumSpecials As Integer
Dim dsConn As New MySql.Data.MySqlClient.MySqlConnection()
Dim myConnectionString As String

myConnectionString = "server=someserver;uid=someuname;pwd=somepasswd;database=someDB"
dsConn.ConnectionString = myConnectionString
oString = "SELECT count(f1) " _
            & "FROM t1" _
            & "WHERE f2= " & ID
Dim cmd As MySqlCommand = New MySqlCommand()
cmd.CommandText = oString
cmd.Connection = dsConn
intNumSpecials = cmd.ExecuteScalar()

MySql.Data.MySqlClient.MySqlException: Table 'DB.T1' doesn't exist at MySql.Data.MySqlClient.PacketReader.CheckForError() at MySql.Data.MySqlClient.PacketReader.ReadHeader() at MySql.Data.MySqlClient.PacketReader.OpenPacket() at MySql.Data.MySqlClient.NativeDriver.ReadResult(Int64& affectedRows, Int64& lastInsertId) at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst) at MySql.Data.MySqlClient.CommandResult..ctor(Driver d, Boolean isBinary) at MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume) at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader) at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() at MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar() at Namespace.Class.Function(Object ID) at Namespace.Class.Bindata(String strAddSearch, String strOrderby)
Question by:CJSantora
    LVL 96

    Accepted Solution

    Try this (with extra spaces):

    oString = "SELECT count(f1) " _
                & " FROM t1" _
                & " WHERE f2= " & ID


    Author Comment

    It turns out that the issue was the table name in the MySql database was all capital letters but my query
    had only the first letter Capitalized. Thanks for the help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now