I have an C# form application that use an access database.
This application works perfectly in debug and release. It works on all version of Windows.
But it crash on one computer with Windows 7.
The message I got is:
System.Data.OleDb.OleDbException: No value given for one or more required parameters.
EDIT, after some debugging with messagebox on the computer that have the problem, here is the code that bug.The error is catched on the cmd.ExecuteReader(). The messagebox juste before is shown and the next one is the one in the catch with the exception below. Any ideas?
public List<CoeffItem> GetModeleCoeff()
{
List<CoeffItem> list = new List<CoeffItem>();
try
{
OleDbDataReader dr;
OleDbCommand cmd = new OleDbCommand("SELECT nIDModelAquacad, nIDModeleBorne, fCoefficient FROM tbl_ModelBorne ORDER BY nIDModelAquacad", m_conn);
MessageBox.Show("Commande SQL créée avec succès");
dr = cmd.ExecuteReader();
MessageBox.Show("Exécution du reader sans problème!");
while (dr.Read())
{
list.Add(new CoeffItem(Convert.ToInt32(dr["nIDModelAquacad"].ToString()),
Convert.ToInt32(dr["nIDModeleBorne"].ToString()),
Convert.ToDouble(dr["fCoefficient"].ToString())));
}
MessageBox.Show("Lecture du reader");
dr.Close();
MessageBox.Show("Fermeture du reader");
}
catch (OleDbException err)
{
MessageBox.Show("Erreur dans la lecture des modèles/coefficient: " + err.ToString());
}
return list;
}
I think it's something related to the connection string but why only on that computer.
Thanks for your help!
EDIT
Here is the complete error message:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
***** Exception Text *******
System.Data.OleDb.OleDbException: No value given for one or more required parameters.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.ExecuteReader()
at DatabaseLayer.DatabaseFacade.GetModeleCoeff()
at DatabaseLayer.DatabaseFacade.InitConnection(String strFile)
at CalculatriceCHW.ListeMesure.OuvrirFichier(String strFichier)
at CalculatriceCHW.ListeMesure.nouveauFichierMenu_Click(Object sender, EventArgs e)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)