Click here to Skip to main content
15,920,217 members
Home / Discussions / Database
   

Database

 
GeneralRe: Query Pin
Steve S10-Feb-04 6:21
Steve S10-Feb-04 6:21 
Generalsimple INSERT question Pin
hkl5-Feb-04 9:12
hkl5-Feb-04 9:12 
GeneralRe: simple INSERT question Pin
Edbert P5-Feb-04 19:07
Edbert P5-Feb-04 19:07 
GeneralConfigure SMTP Pin
DaKhucBuon4-Feb-04 23:08
DaKhucBuon4-Feb-04 23:08 
GeneralRe: Configure SMTP Pin
Vasudevan Deepak Kumar5-Feb-04 0:37
Vasudevan Deepak Kumar5-Feb-04 0:37 
GeneralRe: Configure SMTP Pin
DaKhucBuon5-Feb-04 14:40
DaKhucBuon5-Feb-04 14:40 
GeneralRe: Configure SMTP Pin
Vasudevan Deepak Kumar6-Feb-04 0:53
Vasudevan Deepak Kumar6-Feb-04 0:53 
GeneralAccess/ODBC: Item count fails Pin
mexicanchili4-Feb-04 21:51
mexicanchili4-Feb-04 21:51 
Hi,

I have the following phenomenon: I have a database with several tables and created a union with a Like-Operator in the WHERE-Statement, like this:
<br />
SELECT Key, Value FROM MyTable WHERE Value Like 'RED*'<br />
UNION SELECT Key, Value FROM MySecondTable WHERE Value Like 'RED*';<br />


Now I'm trying to count the items in this view via ODBC, here are the main parts of my CRecordset-derived class doing it:
<br />
CHelperRecordset::CHelperRecordset(CDatabase* pdb)<br />
: CRecordset(pdb)<br />
{<br />
  //{{AFX_FIELD_INIT(CHelperRecordset)<br />
  m_lFetchedCount = 0;<br />
  m_nFields = 1;<br />
  //}}AFX_FIELD_INIT<br />
  m_nDefaultType = forwardOnly;<br />
}<br />
<br />
void CHelperRecordset::DoFieldExchange(CFieldExchange* pFX)<br />
{<br />
  //{{AFX_FIELD_MAP(CHelperRecordset)<br />
  pFX->SetFieldType(CFieldExchange::outputColumn);<br />
  RFX_Long(pFX, _T("ZAEHLER"), m_lFetchedCount);<br />
  //}}AFX_FIELD_MAP<br />
}<br />
<br />
long CHelperRecordset::GetCount(const CString& strTableName, const CString& strIndexName) <br />
{<br />
  CString strSQL = _T("");<br />
  strSQL.Format("Select Count(%s) As ZAEHLER From %s", strIndexName,  strTableName);<br />
  Open(CRecordset::forwardOnly, strSQL);<br />
  Close();<br />
  return m_lFetchedCount;<br />
}<br />


If I'm executing this on my union I will get a count of 0, although all items are visible when I open the union in MS Access. There seems to be nothing wrong with the CHelperRecordset class, when the Like-operator is replaced by =, everythings works fine:
<br />
SELECT Key, Value FROM MyTable WHERE Value='RED'<br />
UNION SELECT Key, Value FROM MySecondTable WHERE Value='RED';<br />


And if I'm not using a union but a view only everything is fine as well, even with the Like-operator:
<br />
SELECT Key, Value FROM MyTable WHERE Value Like 'RED*';<br />


In these cases the correct count is retrieved.

On the PC of my colleague this problem doesn't occur. He is using WinNT4 SP6, Office 2000 (no SR), ODBC-Driver Version 3.520, Access-ODBC-Driver has the 4.00.5303.
I'm using WindowsXP SP1, Office 2000 (SR1, upgrading to SR3 didn't help), ODBC-Driver Version 3.525, Access-Driver is 4.00.6019.

Does anybody know whether there is some obscure option or setting I have to set somewhere or whether this is a MS Bug or whether I am doing something completely wrong? I could easily send the small test application and database with which I reproduced the problem along if anybody's interested.
As I'm no expert in databases, ODBC, SQL and stuff and our expert has left us I'm completely at loss. I wanted to have a look at some completely different problem of our application and cannot do it, because the application fails to see the database items on my pc in the first place.
Any hint or idea would be welcome. Thank you very much.

mexicanchili
GeneralRe: Access/ODBC: Item count fails Pin
mexicanchili5-Feb-04 1:43
mexicanchili5-Feb-04 1:43 
Generaltrouble with IDataParameterCollection and ArrayList Pin
Nik Vogiatzis4-Feb-04 9:52
Nik Vogiatzis4-Feb-04 9:52 
GeneralRe: trouble with IDataParameterCollection and ArrayList Pin
Mike Dimmick5-Feb-04 0:43
Mike Dimmick5-Feb-04 0:43 
GeneralADO.NET Query Timeout Pin
afronaut4-Feb-04 6:28
afronaut4-Feb-04 6:28 
GeneralRe: ADO.NET Query Timeout Pin
Michael Potter4-Feb-04 10:16
Michael Potter4-Feb-04 10:16 
GeneralUsing TOP operator within a WHERE clause Pin
OBRon3-Feb-04 10:33
OBRon3-Feb-04 10:33 
GeneralRe: Using TOP operator within a WHERE clause Pin
David Llamas3-Feb-04 10:39
David Llamas3-Feb-04 10:39 
GeneralRe: Using TOP operator within a WHERE clause Pin
OBRon3-Feb-04 10:45
OBRon3-Feb-04 10:45 
Generaladvanced ADO.NET and Oracle Database Pin
koo93-Feb-04 9:33
koo93-Feb-04 9:33 
GeneralRe: advanced ADO.NET and Oracle Database Pin
Guillermo Rivero3-Feb-04 10:40
Guillermo Rivero3-Feb-04 10:40 
GeneralRe: advanced ADO.NET and Oracle Database Pin
koo93-Feb-04 11:15
koo93-Feb-04 11:15 
GeneralRe: advanced ADO.NET and Oracle Database Pin
Mike Dimmick4-Feb-04 2:39
Mike Dimmick4-Feb-04 2:39 
GeneralUsing UDFs in a SELECT Pin
Colin Angus Mackay3-Feb-04 5:28
Colin Angus Mackay3-Feb-04 5:28 
GeneralRe: Using UDFs in a SELECT Pin
michanne4-Feb-04 3:02
michanne4-Feb-04 3:02 
GeneralRe: Using UDFs in a SELECT Pin
Colin Angus Mackay4-Feb-04 4:28
Colin Angus Mackay4-Feb-04 4:28 
GeneralRe: Using UDFs in a SELECT Pin
michanne4-Feb-04 8:38
michanne4-Feb-04 8:38 
GeneralRe: Using UDFs in a SELECT Pin
Mike Dimmick9-Feb-04 3:51
Mike Dimmick9-Feb-04 3:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.