• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 498
  • Last Modified:

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

0
joshkrak
Asked:
joshkrak
  • 3
  • 2
1 Solution
 
joshkrakAuthor Commented:
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.
0
 
UmeshCommented:
Can you post your table description & insert statement?
0
 
joshkrakAuthor Commented:

'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

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

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now