CDaoRecordset::FindFirst() usage

As a novice on database, I am trying to use CDaoRecordset::FindFirst()
function just to check if certain 'Serial Number' exists in other table but
it throws following error:

Error(3077): Syntax error (missing operator) in expression.

Please see following code:

....

 ASSERT(m_pDB->IsOpen());
 CDaoTableDef td(m_pDB);
 CDaoRecordset rs(m_pDB);

 // convert serial number string to long number
 char *end;
 long UnitNum=lstrtol(GetSerialNum(),&end,10);
 BOOL faulty = FALSE;

 try {
  td.Open((LPCTSTR)(_T("Table 1")));
 }
 catch (CDaoException* e) {
  m_pView->DisplayDaoException(e);
  e->Delete();
  return FALSE;
 }
 nFieldCount = td.GetFieldCount();
 td.Close();

 try
 {
  strSel=(_T("Select * From ["));
  strSel += (LPCTSTR)(_T("Table 1"));
  strSel += _T("]");
  rs.Open(dbOpenDynaset,strSel);

  find.Format("Serial Number = %i", UnitNum);
 }
 catch( CDaoException* e )
 {
  m_pView->DisplayDaoException(e);
  e->Delete();
  return FALSE;
 }

 // rs is a dynaset-type recordset previously opened
 try
 {
  if (rs.FindFirst(find))    // Error(3077): Syntax error (missing operator)
in expression.
   faulty = TRUE;
 }
 catch( CDaoException* e )
 {
  m_pView->DisplayDaoException(e);
  e->Delete();
  return FALSE;
 }
 rs.Close();
....

Regards
Bob


0
bbg9507 (39)
9/17/2004 5:22:52 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
927 Views

Similar Articles

[PageSpeed] 19

On Fri, 17 Sep 2004 17:22:52 +1200, Bob wrote:

> As a novice on database, I am trying to use CDaoRecordset::FindFirst()
> function just to check if certain 'Serial Number' exists in other table but
> it throws following error:
> 
>   find.Format("Serial Number = %i", UnitNum);

The problem is probably that you have a field name that includes *spaces* !

either change the field name or put the field name inside [] in the SQL
sentence. E.g. find.Format("[Serial Number] = %i",UnitNum);

// Anders
0
9/17/2004 6:52:26 AM
Reply:

Similar Artilces:

CDaoRecordset::movingRecordToAnotherTable?
Hi there, I am working on simple database like 'Product Tracking.mdb' What would be the easiest way to move certain record from table1 to table2? Both tables have the same structure and have a key field 'Serial Number'. Table1 doesn't allow duplicate Serial Number so, when I have a new data to be added to table1 but that serial number already exists in table1, I want to move(copy and delete) that record to table2. Thanks Bob ...

Using the CDaoRecordset
Hello, I'm trying use CDaoRecordset (find) function to filter out the specified record, how can use the result/row returned to show the relevant record detail? For example: I'm using CDaoRecordset find function for finding a record named "contact_id". if the find function found a matched result. I would like to show the relevant record detail (e.g: contact_name, contact_phone_no) for the matched "contact_id" how can do these? Thanks for all kindly assistance ^^ Jasper On Sun, 26 Sep 2004 11:21:53 +0800, aON wrote: > Hello, > I'm trying use CDaoRecor...

Error 3077 Recordset.FindFirst using dates
I am using Access2007 and VB 98 . I have a table whose model is as follows: tblPays FromDate ToDate MonthlyPay 01/03/2008 29/02/2008 7770 01/03/2009 28/02/2009 7970 01/03/2009 28/02/2010 8300 The dates are formatted in Indian Style(dd-mm-yyyy) I have a function now to find the monthly pay rate for a particular period. For example, the period 01-10-2008 To 31-12-2008 should give the monthly rate: 7770 Function MyPay(datFromDate,datToDate) Dim db AS Dao.Database Dim rst AS Dao.Recordset Set rst = db.openrecordset(tblpays,dbopendynaset) “ Now I want to find the monthly p...

RESOURCE USAGE 03-21-10
I work with a calendar that is setting 9 hours work/day for all the resources. In the resource usage I see that more than 8 hours of work is shown in red, but also sometimes all kinds of hours like 4.5, 5.6, 4.8 hs is red as well, even though is a normal working day. What is going on here???? txs A couple of things: 1) Are you sure the resource calendars are also set to 9 hours per day? If not, they would show up overallocated when assigned to 9 hours of tasks. 2) Project calculates overallocations to the minute. If you have two tasks, both assigned to the same resource...

Usage of Data Validation with If Condition
I am using Data validation in a sheet, that is working well as per my requirement. Now I want to use this with IF Condition. Mean if a cell has some particular value then Data Validation should work otherwise it shows blank value on the same column where I have applied data validation (LIST) Hi, I have the same problem and i need a solution very urgently! Thanks! "Mujeeb ur Rehman, FBL-GRW-PK" wrote: > I am using Data validation in a sheet, that is working well as per my > requirement. > > Now I want to use this with IF Condition. > > Me...

Distribution List usage information
Hi, Anyone know how I can tell when a Distribution List was last used as a recipient in an email? I am trying to clean up some old DLs in our enviornment and it would be useful to know when they were last used. Thanks, Mark The information is tracked in the message tracking logs. You can collect some stats from them, though they may not go back far enough for you. You might need to set up a script to process them over the course of a month or more to get a solid idea. They're fairly easy to process, or there are products like promodag and messagestats that will do some reports ou...

gpconnNet.dll usage
Sirs: I have been searching for documentation on the gpconnNet.dll. I am developing a .NET integration and need to look up data. I don't want to use ADO, I need to use datasets and the SQLClient structure. In order to do that, I need to build a connection string to feed to the SQL Helper. Will gpConnNet give me the encrypted password? Is there documentation on how to use it? Hi Steve - yes GPConnet.dll will allow you to make a connection. We are using it in our Web T&E product. It is a little fussy and we have found enviroments where it does not validate correctly. MS is ...

Inefficient Space Usage
Can anybody tell me how to get rid of a little box that reads "Drag a Column Header Here to Group by that Column"? The grey box causes the entire grey inbox area to expand, which wastes space on my screen. I've spent hours trying to get rid of it, but cannot, and it drives me crazy that it is there. Thanks, Steve Rightclick the top columns (From, Subject, etc) and choose Group By Box -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Office related News Also Outlook FAQ, How To's, Downloads and more... Tip of the month: -Tips for cleaning up your mai...

CListView and CDaoRecordset
I have a List View which is made up of records in a Recordset. What is the proper way to handle creating the listview? open recordset loop through recordset add record to listview close recordset ????? or should I keep it open Now the user chooses to pop up a dialog box to add a new record. Do I use the same recordset or do I create a new one and have them enter into that recordset. when the dialog box is finished how should I get the record into the list view? should I use AddItem or should I read the original recordset again and populate the list anew. William, "William Gower&...

EURO Usage
How best to list prices in Euros? Is it best/easiest to paint the Euro in using Alt0128, or some other way? Tools, Adins shows a Euro Currency option but I don't have the disk or know how to get it. Please advise. As you did not mention which version of Office/Excel you have. So I can not tell you what you need exactly. Anyway have a look here http://tinyurl.com/puqc and find the required file to download from there. HTH "Old Red One" <oldred1@charter.net> wrote in message news:OvC0EV5iDHA.724@tk2msftngp13.phx.gbl... > How best to list prices in Euros? Is it bes...

Edit record after FindFirst in CDaoRecordset
I am trying to edit a CDaoRecordset that is open dynaset. The online doc. for FindFirst said: "If Find returns nonzero, the current record is not defined. In this case, you must position the current record pointer back to a valid record." I take this to mean that I need to do a MovePrev() before I edit the record, but this seem not to be right. I edit the wrong record or throw an exception. What is the right way to edit a record after a FindFirst(). Thanks "David Briggs" <dlbriggs1729@yahoo.com> ???????/???????? ? ???????? ?????????: news:376a9322.0408020810.28c...

Problem with a CDaoRecordSet
Hello gruop. I'm novice in VC. I'm programming a aplication with MDI and I'm using a CDaoRecordset but I have two problem. 1. How can I connect the CDaoRecordset with my MySQL database? In the wizard I only can connect the CDaoRecordset with a database file (*.mdb) but ir doesn't give the option to use another type of database. 2. In the CDaoRecordwiew of CDaoRecordset, how can I insert a grid control? For me, is the same that the grid control are DBGrid, MsGrid, FlexGrid or another. Can anybody help me? Thanks in advance. ...

How to disable the usage of "Permanently Deleting Items"
Hello, I want to disable the usage of "Permanently Deleting Items" for every user. Is there a way to disable this on the Exchange server or with Outlook. Every object must go into the folder deleted items. This setup shall help for better recovery support. Thanks Frank ...

CDaoRecordset question
If I have two tables having the exact same fields, is there any reason why I can't have one recordset class handle them both? Will I run in any problems? They will never be both open at the same time. ...

null date issue when using findfirst
hey all, I'm using a listbox that displays the number, organization, name and date from a distribution table. unfortunately, there is no key column (for various reasons) so i've modified the underlying code for the AfterUpdate action so it looks for the record matching all 4 fields in the listbox. However, I run into a problem where there is no date filled in, I get a syntax error. How can Imodify my code below to include the field, as it is vital in some cases, but not get an error where there is no date? Thanks in advance!!! "aft3rgl0w" <aft3rgl0w@discussions...

MS Project 2007 Resource Usage View
Hi, In MS Project 2007, in Resource Usage view, the dates shown are EARLY dates, how can I show the same using LATE dates? Thank you, Hello Muny, I'm guessing you have added the Early Start field to the Usage table (left side) of the Resource Usage view. You may add the Late Start and Late finish through Insert > Column. I hope this helps. Let us know how you get along. Julie Project MVP Visit http://project.mvps.org/ for the FAQs and additional information about Microsoft Project On 2/22/2010 10:36 AM, Muny wrote: > Hi, > > In MS Project 200...

determine last usage of a DL in Ex55
Hello! I would need to find out when a distirbution list was last used in order to perform a cleanup of unused DLs. Can anybody give me a hint how to do this? I heard something about a Public Folder as a member of the DL... How does this work? Thanks! BR, Joe ...

CDaoRecordSet no longer supported
I got this warning message the other day. My interpretation is that CDaoRecordset will no longer be supported by MS. What's going on here? ********************************************************* c:\ActBooks Dev 2007\ReporterSet.h(18): warning C4995: 'CDaoRecordset': name was marked as #pragma deprecated ********************************************************* Thanks, Neil You should use ADO instead. Jet is deprecated. You should consider using Microsoft Desktop Engine (MSDE) or SQL Server 2005 Express Edition as the entry-level database engine. -- Regards Sheng Jiang Mic...

ram usage of store.exe?
Hi all. I don't know what's going on on my win2003sbs server.. it is a file server and exchange. a few weeks earlier, I do added a backup for recovery of mail. the recovery store do removed now. things seem okay... except that the memory usage of store.exe is too high... the server has got 768MB ram... then store.exe take 4xxMB usage... amm... when it just boot up, everythings is okay, has got 3xxMB free Ram.. but next day, store.exe take 4xxMB and only 4xMB free ram... Please help.. thanks Hi Louis, Store.exe will use as much spare memory as it can get a hold of, this impro...

Assignement Data Different on Task Usage from Resource Usage View
Hi Project Server Users, We are using PS 07 SP2 Aug09 MS CU. I know I saw data on this issue, but have not been able to find it. We are seeing different assignement data on the Task Usage view from Resource Usage view for resources We are not using the Load Summary Resource Assignments option. I would appreciated pointing me to the data on this issue. Thanks, On May 12, 11:35=A0am, BruceFFIC <breyn...@ffic.com> wrote: > Hi Project Server Users, > > We are using PS 07 SP2 Aug09 MS CU. > > I know I saw data on this issue, but have not been able to ...

CDaoRecordset and Access
Is it possible to access the description field in an Access Table? Not with CDaoRecordset, or the other DAO library. The option that comes to mind is to use MS Access as a COM server (using #import) and call the MS Access interfaces directly. Later versions of ADO may support it. - Tim "William Gower" <w_gower@hotmail.com> wrote in message news:e0eTBzfgDHA.1668@TK2MSFTNGP12.phx.gbl... > Is it possible to access the description field in an Access Table? > > ...

How can I add a CDaoRecordview and/or CDaoRecordset class to a project in VC2003?
Hello group I have a problem. I don't know how add CDaoRecordset or/and CDaoRecordview class to a project in VC2003. In VC 6 I know,but with VC2003 I do: 1. Click Project. 2. Add Class 3. Click Category/MFC -> MFC class 4. I don't see the CDaoRecordset or/and CDaoRecordview class in base class list. Please anybody, help me!!! Thank's in advance ...

CDaoRecordset, MS Access 2002 and VC++ 6.0
Has anyone successfully used CDaoRecordset in VC++ 6.0 to querry an Access 2003 database? When I used the ClassWizard to setup a CDaoRecordset class I get "Unrecognized database format". I have also tried some sample code from "Programming Visual C++" by D Kruglinski and when I ran the program the error was... "DAO error 3343, SOURCE = DAO.Workspace, DESCR = Unrecognized database format " I have the latest service pack for Visual C++, DAO and Jet 4.0. ...

How to avoid 100% CPU Usage (possible OT)
Hi, When I'm running my software on my computer, the CPU usage is maximum 50%. However, recently a couple of customers are reporting that our software makes the CPU usage go to 100%, meaning other applications are unusable. How do I fix this? Thanks. >When I'm running my software on my computer, the CPU usage is maximum >50%. You've got a multi/dual core or hyperthreaded processor. >However, recently a couple of customers are reporting that our >software makes the CPU usage go to 100% Your customers have a single processor. >How do I fix this? It depends wha...

CPU usage
Hello, I am having difficulty with Outlook (XP)2002. After some minuites of it being loaded the Outlook CPU usage frequently goes up to nearly 100%. Often after quitting Outlook the regular way the proces stays resident (and the CPU usages remains near 100%) and I have to Cntl- Alt-Del to properly end the task. I have installed the most recent updates. Any ideas on how I can fix this problem? Thank you. Sincerely, Jim ...