MySQL .NET Connector Error

Posted on 2008-11-19
Last Modified: 2012-05-05
I Have a WCF webservice that uses a separate MVC assembly to form object from a database using. The MVC contains the reference to the MySQL connector but every time I try to run a query I get the following the error shown in code.. I know my connection is right because I've copy and pasted it directly form a working windows app.. Is there something new with how WCF webservices work or it a problem that I have the methods in a separate assembly?

"Key cannot be null. Parameter name: key"

Stack Track:

   at System.Collections.Hashtable.ContainsKey(Object key)

   at System.Collections.Hashtable.Contains(Object key)

   at MySql.Data.MySqlClient.MySqlPoolManager.GetPool(MySqlConnectionStringBuilder settings)

   at MySql.Data.MySqlClient.MySqlConnection.Open()

   at System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)

   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)

   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

Open in new window

Question by:joshkrak
    LVL 26

    Expert Comment


    Author Comment

    Lol, yea, this was the first one I saw, but if you look at my stack trace, the error is coming from within the managed mysql connector. My code has abosultely nothing to do with hashtables. Its a DataTable that I'm trying to fill.
    LVL 26

    Accepted Solution

    Can you post your table description & insert statement?

    Author Comment


    'aff_id', 'int(10) unsigned', 'NO', 'PRI', '0', ''
    'delta', 'int(10) unsigned', 'NO', 'PRI', '0', ''
    'aff_name', 'varchar(45)', 'YES', '', '', ''
    'created', 'datetime', 'YES', '', '', ''
    aff_id and delta form the primary key
    I actually get this error regardless of it being a SELECT or INSERT
    SELECT Statement:
    SELECT * FROM affiliates WHERE aff_id=?AffId ORDER BY delta DESC LIMIT 1
    The code that exectues the command (Parameters where added before hand)
                    Dim Adapt As New MySqlDataAdapter(Cmd)
                    Adapt.FillLoadOption = LoadOption.OverwriteChanges
                    Adapt.AcceptChangesDuringFill = True
    Connection string

    Open in new window


    Author Comment

    Omg, this is embarrassing. I wasnt passing in the connectionstring when initializing the MySqlConnection :(

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now