473,385 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ADODB Find/ Seek method in C# 2005

Hi ,
I am using ADO (ADODB) with access database. Not sure what I am doing
wrong.here. Can anyone please help me?

string mdbFile = System.IO.Directory.GetCurrentDirectory() +" \\bTrack.mdb;"
ADODB.Connection conn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
string connString =string.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source={0}", mdbFile);
string query = "Select * from Client";
conn.ConnectionString = connString;
conn.Open(null, null, null, 0);
rs.Open(query, conn, ADODB.CursorTypeEnum.adOpenKeyset,
ADODB.LockTypeEnum.adLockOptimistic, -1);
rs.Find("ID='" + myID+"'", 0,
ADODB.SearchDirectionEnum.adSearchForward,null);== Get COMException Error
here

Thank you

Bryan


Oct 18 '07 #1
7 4122
Bryan,

What is the exception error you are getting?

Also, do you have a need to select all the records at once? Why not
just filter based on the id?

Finally, why not use the classes in the System.Data.OleDb namespace?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bryan" <ca*******@lycos.comwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
Hi ,
I am using ADO (ADODB) with access database. Not sure what I am doing
wrong.here. Can anyone please help me?

string mdbFile = System.IO.Directory.GetCurrentDirectory() +"
\\bTrack.mdb;"
ADODB.Connection conn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
string connString =string.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source={0}", mdbFile);
string query = "Select * from Client";
conn.ConnectionString = connString;
conn.Open(null, null, null, 0);
rs.Open(query, conn, ADODB.CursorTypeEnum.adOpenKeyset,
ADODB.LockTypeEnum.adLockOptimistic, -1);
rs.Find("ID='" + myID+"'", 0,
ADODB.SearchDirectionEnum.adSearchForward,null);== Get COMException Error
here

Thank you

Bryan


Oct 18 '07 #2
Hi Nicholas,
Here are the Error Details. Well I am using Microsoft Access
Database and I am new to c# , dont know lot about ADO.Net thats why I tried
to use ADODB instead of ADO.NET. I am trying to navigate to next record. If
you see the code I am opening recordset and find record which will match id
.. I dont know how to do this in ADO.NET

Thank you for your response.

Bryan

System.Runtime.InteropServices.COMException was unhandled
HelpLink="C:\\WINDOWS\\HELP\\ADO270.CHM#1240652"
Message="Application uses a value of the wrong type for the current
operation."
Source="ADODB.Recordset"
ErrorCode=-2146824867
StackTrace:
at ADODB.RecordsetClass.Find(String Criteria, Int32 SkipRecords,
SearchDirectionEnum SearchDirection, Object Start)
at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target,
RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source,
RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEven tArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArg s e)
at System.Windows.Controls.Button.OnClick()
at
System.Windows.Controls.Primitives.ButtonBase.OnMo useLeftButtonUp(MouseButtonEventArgs
e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk( Object sender,
MouseButtonEventArgs e)
at
System.Windows.Input.MouseButtonEventArgs.InvokeEv entHandler(Delegate
genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler,
Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target,
RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source,
RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(RoutedEven tArgs args,
RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender,
MouseButtonEventArgs e)
at
System.Windows.Input.MouseButtonEventArgs.InvokeEv entHandler(Delegate
genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler,
Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target,
RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source,
RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEven tArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArg s args, Boolean
trusted)
at System.Windows.Input.InputManager.ProcessStagingAr ea()
at System.Windows.Input.InputManager.ProcessInput(Inp utEventArgs
input)
at System.Windows.Input.InputProviderSite.ReportInput (InputReport
inputReport)
at System.Windows.Interop.HwndMouseInputProvider.Repo rtInput(IntPtr
hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x,
Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.Filt erMessage(IntPtr
hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessa ge(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation( Object o)
at
System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate
callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object
source, Delegate callback, Object args, Boolean isSingleParameter, Delegate
catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(Dis patcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Boolean
isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(Dispatc herPriority
priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg,
IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl( DispatcherFrame
frame)
at System.Windows.Threading.Dispatcher.PushFrame(Disp atcherFrame
frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Oct 18 '07 #3
Bryan wrote:
Well I am using Microsoft Access
Database and I am new to c# , dont know lot about ADO.Net thats why I tried
to use ADODB instead of ADO.NET.
Switch to ADO.NET OLE DB provider.

Much easier.

Arne
Oct 19 '07 #4
Did you run a "auto up converter" to do that.

You probably need to google

DataSet
IDataReader

OleDBProvider.

There isn't really any good reason to use ADO in DotNet.

ADO.Net is not ADO.

You can also get the EnterpriseLibrary(.Data), and it will make using Access
(most datasources really).
Make the jump, dude.


"Bryan" <ca*******@lycos.comwrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
Hi ,
I am using ADO (ADODB) with access database. Not sure what I am doing
wrong.here. Can anyone please help me?

string mdbFile = System.IO.Directory.GetCurrentDirectory() +"
\\bTrack.mdb;"
ADODB.Connection conn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
string connString =string.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source={0}", mdbFile);
string query = "Select * from Client";
conn.ConnectionString = connString;
conn.Open(null, null, null, 0);
rs.Open(query, conn, ADODB.CursorTypeEnum.adOpenKeyset,
ADODB.LockTypeEnum.adLockOptimistic, -1);
rs.Find("ID='" + myID+"'", 0,
ADODB.SearchDirectionEnum.adSearchForward,null);== Get COMException Error
here

Thank you

Bryan


Oct 19 '07 #5
Any idea where I can find sample code? tutorials?

"Arne Vajhøj" <ar**@vajhoej.dkwrote in message
news:47***********************@news.sunsite.dk...
Bryan wrote:
> Well I am using Microsoft
Access Database and I am new to c# , dont know lot about ADO.Net thats
why I tried to use ADODB instead of ADO.NET.

Switch to ADO.NET OLE DB provider.

Much easier.

Arne

Oct 19 '07 #6
Bryan,

I think you would want to not encapsulate the ID field in quotes in the
call to Find. My guess is the ID field is an integer.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bryan" <ca*******@lycos.comwrote in message
news:u%****************@TK2MSFTNGP06.phx.gbl...
Hi Nicholas,
Here are the Error Details. Well I am using Microsoft
Access Database and I am new to c# , dont know lot about ADO.Net thats why
I tried to use ADODB instead of ADO.NET. I am trying to navigate to next
record. If you see the code I am opening recordset and find record which
will match id . I dont know how to do this in ADO.NET

Thank you for your response.

Bryan

System.Runtime.InteropServices.COMException was unhandled
HelpLink="C:\\WINDOWS\\HELP\\ADO270.CHM#1240652"
Message="Application uses a value of the wrong type for the current
operation."
Source="ADODB.Recordset"
ErrorCode=-2146824867
StackTrace:
at ADODB.RecordsetClass.Find(String Criteria, Int32 SkipRecords,
SearchDirectionEnum SearchDirection, Object Start)
at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object
target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source,
RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEven tArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArg s e)
at System.Windows.Controls.Button.OnClick()
at
System.Windows.Controls.Primitives.ButtonBase.OnMo useLeftButtonUp(MouseButtonEventArgs
e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk( Object sender,
MouseButtonEventArgs e)
at
System.Windows.Input.MouseButtonEventArgs.InvokeEv entHandler(Delegate
genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler,
Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object
target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source,
RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(RoutedEven tArgs args,
RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender,
MouseButtonEventArgs e)
at
System.Windows.Input.MouseButtonEventArgs.InvokeEv entHandler(Delegate
genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler,
Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object
target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source,
RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEven tArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArg s args, Boolean
trusted)
at System.Windows.Input.InputManager.ProcessStagingAr ea()
at System.Windows.Input.InputManager.ProcessInput(Inp utEventArgs
input)
at System.Windows.Input.InputProviderSite.ReportInput (InputReport
inputReport)
at System.Windows.Interop.HwndMouseInputProvider.Repo rtInput(IntPtr
hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x,
Int32 y, Int32 wheel)
at
System.Windows.Interop.HwndMouseInputProvider.Filt erMessage(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessa ge(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation( Object o)
at
System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate
callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object
source, Delegate callback, Object args, Boolean isSingleParameter,
Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(Dis patcherPriority
priority, TimeSpan timeout, Delegate method, Object args, Boolean
isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(Dispatc herPriority
priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg,
IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl( DispatcherFrame
frame)
at System.Windows.Threading.Dispatcher.PushFrame(Disp atcherFrame
frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Oct 19 '07 #7
Nicholas,
I tried taking out quotes still I get same error..

Thank you

Bryan
Oct 19 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Randi | last post by:
Hi all, I have this project to use the ADODB control to acces and manipulate the Access DB. I amd the mistake of first doing this project with just the data control. It worked fine with this...
11
by: Manuel Lopez | last post by:
From what I've read in the docs, ado.net currently supports opening sql server ce tables in table-direct mode and performing Seek operations on them (using SqlCeDataReader), but not on the...
1
by: Waitman Gobble | last post by:
Hello, I am new to Python. I am having trouble with zipfile.py. On a Linux machine with python 2.4.2 I have trouble opening a zipfile. Python is complaining about the bit where it does a...
5
by: MLH | last post by:
I have a table I can open as table type recordset or a dynaset. Searching for a particular value in the table's main keyfield, which would be faster and less strain on the application......
11
by: Tiger | last post by:
We can use seek() in the FileStream class,as we know. But I found that seek() is not work correctly in StreamReader. Who can tell me how to use seek() correctly in StreamReader? thanks a lot! I...
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
4
by: Fresh_Air_Rider | last post by:
Hi In the "good old" Classic ASP days, I used to stream records from a SQL Server database out to the user's browser in CSV format by using a combination of COALESCE and the ADODB.Stream object....
8
by: Ben | last post by:
Hi! I already sent this to the ACCESS newsgroup. But since I do not know really which side is really causing the problem, I have decided to send this inquiry to this newsgroup also, if I may....
7
Walt in Decatur
by: Walt in Decatur | last post by:
I'm trying to use this method to copy an range in Excel workbook that is closed to the one that's open. I'm using the following code, which gets the "Can't find installable ISAM" error when I get to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.