Baruch F

Baruch F

  • NA
  • 15
  • 0

data access

Jul 9 2008 4:40 AM
I am trying to access an access database and while I am new at this, I have used code from about 10 different places and it all seems to be like they said yet I get an error.  Here is my connection sequence.

string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\HHA.MDB;Persist Security Info=False;";
                OleDbConnection cn = new OleDbConnection(conn);   
                cn.Open();
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = cn;           
                cmd.CommandText = "SELECT EFFECTIVE_DATE, M0100_ASSMNT_REASON, M0020_PAT_ID FROM HHA";
                OleDbDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

When it goes to create the data reader i get the following error:


System.Data.OleDb.OleDbException was unhandled
  Message="No value given for one or more required parameters."
  Source="Microsoft JET Database Engine"
  ErrorCode=-2147217904
  StackTrace:
       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 StartOfCare.MainForm.MainForm_Load(Object sender, EventArgs e) in C:\prog\Assessments\StartOfCare\MainForm.cs:line 42
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at StartOfCare.Program.Main() in C:\prog\Assessments\StartOfCare\Program.cs:line 17
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()


Any help would be greatly appreciated



Answers (1)