ADO database : updating and/or adding

Started by
4 comments, last by da_cobra 18 years, 11 months ago
I have the following recordset :

class CADORecSet : public CADORecordBinding
{
	BEGIN_ADO_BINDING(CADORecSet)
		ADO_FIXED_LENGTH_ENTRY		( 1, adInteger, m_lnID,												m_ulIDStatus,					false) 
		ADO_VARIABLE_LENGTH_ENTRY2	( 2, adVarChar, m_szNaam,			  sizeof(m_szNaam),				m_ulNaamStatus,					true)
		ADO_VARIABLE_LENGTH_ENTRY2	( 3, adVarChar, m_szVoornaam,	  	  sizeof(m_szVoornaam),			m_ulVoornaamStatus,				true)
		ADO_VARIABLE_LENGTH_ENTRY2	( 4, adVarChar, m_szBijnaam,		  sizeof(m_szBijnaam),			m_ulBijnaamStatus,				true)
		ADO_FIXED_LENGTH_ENTRY		( 5, adInteger, m_nTypeAdres1,										m_ulTypeAdres1Status,			true) 
		ADO_FIXED_LENGTH_ENTRY		( 6, adInteger, m_nTypeAdres2,										m_ulTypeAdres2Status,			true)
		ADO_VARIABLE_LENGTH_ENTRY2	( 7, adVarChar, m_szNaamAdres1,		  sizeof(m_szNaamAdres1),		m_ulNaamAdres1Status,			true)
		ADO_VARIABLE_LENGTH_ENTRY2	( 8, adVarChar, m_szStraat1,		  sizeof(m_szStraat1),			m_ulStraat1Status,				true)
		ADO_VARIABLE_LENGTH_ENTRY2	( 9, adVarChar, m_szNummer1,		  sizeof(m_szNummer1),			m_ulNummer1Status,				true)
		ADO_VARIABLE_LENGTH_ENTRY2	(10, adVarChar, m_szStad1,			  sizeof(m_szStad1),			m_ulStad1Status,				true)
		ADO_FIXED_LENGTH_ENTRY		(11, adInteger, m_nPostcode1,										m_ulPostcode1Status,			true)
		ADO_VARIABLE_LENGTH_ENTRY2	(12, adVarChar, m_szLand1,			  sizeof(m_szLand1),			m_ulLand1Status,				true)
		ADO_VARIABLE_LENGTH_ENTRY2	(19, adDate,	m_ctimeGeboorteDatum, sizeof(m_ctimeGeboorteDatum), m_ulGeboorteDatumStatus,		true)
		ADO_FIXED_LENGTH_ENTRY		(20, adInteger, m_nTypeTel1,										m_ulTypeTel1Status,				true)
		ADO_FIXED_LENGTH_ENTRY		(21, adInteger, m_nTypeTel2,										m_ulTypeTel2Status,				true)
		ADO_FIXED_LENGTH_ENTRY		(22, adInteger, m_nTypeTel3,										m_ulTypeTel3Status,				true)
		ADO_FIXED_LENGTH_ENTRY		(23, adInteger, m_nTypeTel4,										m_ulTypeTel4Status,				true)
		ADO_VARIABLE_LENGTH_ENTRY2	(24, adVarChar, m_szTel1,			  sizeof(m_szTel1),				m_ulTel1Status,					true)
		ADO_VARIABLE_LENGTH_ENTRY2	(25, adVarChar, m_szTel2,			  sizeof(m_szTel2),				m_ulTel2Status,					true)
		ADO_VARIABLE_LENGTH_ENTRY2	(26, adVarChar, m_szTel3,			  sizeof(m_szTel3),				m_ulTel3Status,					true)
		ADO_VARIABLE_LENGTH_ENTRY2	(27, adVarChar, m_szTel4,			  sizeof(m_szTel4),				m_ulTel4Status,					true)
	END_ADO_BINDING()

public:
	CADORecSet() ;
	virtual ~CADORecSet() ;

	long int			m_lnID ;
	ULONG				m_ulIDStatus ;
	CHAR				m_szNaam[21] ;
	ULONG				m_ulNaamStatus ;
	CHAR				m_szVoornaam[21] ;
	ULONG				m_ulVoornaamStatus ;
	CHAR				m_szBijnaam[21] ;
	ULONG				m_ulBijnaamStatus ;
	int					m_nTypeAdres1 ;					// 0 = geen, 1 = adres prive, 
	ULONG				m_ulTypeAdres1Status ;
	int					m_nTypeAdres2 ;					// 2 = adres werk, 3 = andere
	ULONG				m_ulTypeAdres2Status ;
	CHAR				m_szNaamAdres1[21] ;
	ULONG				m_ulNaamAdres1Status ;
	CHAR				m_szStraat1[26] ;
	ULONG				m_ulStraat1Status ;
	CHAR				m_szNummer1[11] ;
	ULONG				m_ulNummer1Status ;
	CHAR				m_szStad1[21] ;
	ULONG				m_ulStad1Status ;
	int					m_nPostcode1 ;
	ULONG				m_ulPostcode1Status ;
	CHAR				m_szLand1[21] ;
	ULONG				m_ulLand1Status ;
	CTime				m_ctimeGeboorteDatum ;
	ULONG				m_ulGeboorteDatumStatus ;
	int					m_nTypeTel1 ;					// 0 = geen, 1 = telefoon prive, 
	ULONG				m_ulTypeTel1Status ;
	int					m_nTypeTel2 ;					// 2 = telefoon werk, 3 = GSM prive, 
	ULONG				m_ulTypeTel2Status ;
	int					m_nTypeTel3 ;					// 4 = GSM werk, 5 = fax prive, 
	ULONG				m_ulTypeTel3Status ;
	int					m_nTypeTel4 ;					// 6 = fax werk
	ULONG				m_ulTypeTel4Status ;
	CHAR				m_szTel1[21] ;
	ULONG				m_ulTel1Status ;
	CHAR				m_szTel2[21] ;
	ULONG				m_ulTel2Status ;
	CHAR				m_szTel3[21] ;
	ULONG				m_ulTel3Status ;
	CHAR				m_szTel4[21] ;
	ULONG				m_ulTel4Status ;
	
} ;

I've shorted a little bit, mine is alot bigger! when I run this code :

strcpy(m_rsADORecSet.m_szNaam,			m_strNaam) ;	strcpy(m_rsADORecSet.m_szVoornaam,		m_strVoornaam) ;
strcpy(m_rsADORecSet.m_szTel1,			m_strTel1) ;
m_rsADORecSet.m_nTypeTel1			=	m_nTypeTel1 ;

MessageBox(NULL, m_strTel1, "checking", MB_OK) ;
MessageBox(NULL, m_rsADORecSet.m_szTel1, "checking", MB_OK) ;

try
{
	m_piAdoRecordBinding->Update(&m_rsADORecSet) ;
}
catch(_com_error &e)
{
	AfxMessageBox(e.Description()) ;
}
}
	
MessageBox(NULL, m_rsADORecSet.m_szTel1, "Checking", MB_OK) ;

no errors in the try/catch, m_szNaam & m_szVoornaam is saved, but m_szTel1 and m_nTypeTel1 not?!? as you can see I check if the m_nTel1 is the correct value in my recordset and it is, but it's still not saved? What am I doing wrong here, I don't understand it anymore :(
Advertisement
Noone that can point me in the right direction? :(
I don't see any obvious error here.
But for what it's worth, some things to check:

- As I understand, both m_rsADORecSet.m_szTel1 and m_strTel1 contain the correct values?
- These values do not exceed the length of 21 characters?
- All the field names, data types and lengths of the table are correct?
- Maybe missing a trailing '\0' character (if that's neccessary)?
- Have you tried saving the telephone number in the naam field for instance. Or tried to save the name value in the telephone field. Just the get an idea of what's going on.

Hope it helps (at least my reply will get your post right on top of the forum listing again [smile]).
- both m_rsADORecSet.m_szTel1 and m_strTel1 contain the right values, yes
- they do not exceed 21 characters
- just checked the table (again) and all names are correct
- '\0' isn't neccessary
- just switched the values of m_strTel1 and m_strNaam and it stays the same, m_strNaam is saved, but m_strTel1 not :(
I found something new!
If there is already something in that field (which I added through MS Access) then I can change that field, through my application. But if there is nothing in it, then I can't also change that?!?

someone? anyone? :(

This topic is closed to new replies.

Advertisement