Link to home
Start Free TrialLog in
Avatar of joshkrak
joshkrakFlag for United States of America

asked on

MySQL .NET Connector Error

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

Avatar of Umesh
Umesh
Flag of India image

Avatar of joshkrak

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Umesh
Umesh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

'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)
 
                OpenConn(Cmd)
                Dim Adapt As New MySqlDataAdapter(Cmd)
                Adapt.FillLoadOption = LoadOption.OverwriteChanges
                Adapt.AcceptChangesDuringFill = True
                Adapt.Fill(dt)
 
Connection string
Server=localhost;Port=3306;Database=dbase;User=myuser;Password=mypassword;

Open in new window

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