|
Hi,
I have developed a small application, using ODBC with Access.
I then ported my tables to SQL Server 2000.
When I Open() a Recordset, all my tables are opened in read/write-mode, except two tables, that I use all the time.
These two tables differ from the other tables only, that they contain a CTime field.
Here is my code
Favorit.m_strFilter="Username='"+myUser+"' AND Dokument='"+Number+"'";
Favorit.Open();
if(!Favorit.IsBOF())
{
Favorit.MoveFirst();
Favorit.Edit();
}
else
{
Favorit.AddNew();
Favorit.m_User=myUser;
Favorit.m_Dokument=Number;
Favorit.SetFieldNull(&(Favorit.m_Gelesen));
}
Favorit.m_Favorit=bChecked;
Favorit.Update();
Favorit.Close();
When AddNew() I get the message, that this record is readonly. It works well in Access, but AddNew() throws an exception, that this record is readonly. Why? And how can I repair it?
Juergen
|
|
|
|
|
What does CRecordset::CanUpdate() indicate?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
CanUpdate() returns FALSE right after Open()
I also checked the rights on my SQL-Server but they seem to be ok. All other tables work well even when Update() is called.
I also dropped the table and created it new. Same effect
Juergen
|
|
|
|
|
e-DJ wrote: CanUpdate() returns FALSE right after Open()
Are JOIN s involved?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Nope,
it's just a plain table.
DBFavoriten::DBFavoriten(CDatabase* pdb)
: CRecordset(pdb)
{
m_Dokument = _T("");
m_User = _T("");
m_Favorit = 0;
m_Gelesen=CTime(NULL);
m_nFields = 4;
m_nDefaultType = dynaset;
}
CString DBFavoriten::GetDefaultConnect()
{
return _T("ODBC;DSN=QM-DB");
}
CString DBFavoriten::GetDefaultSQL()
{
return _T("[Gelesen]");
}
void DBFavoriten::DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Text(pFX, _T("[Dokument]"), m_Dokument);
RFX_Text(pFX, _T("[Username]"), m_User);
RFX_Long(pFX, _T("[Favorit]"), m_Favorit);
RFX_Date(pFX, _T("[Gelesen]"), m_Gelesen);
}
Juergen
|
|
|
|
|
Is the QM-DB DSN configured as read-only?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
No,
as I said before, my database contains about 7 tables. All of them work perfectly well, except the one mentioned.
I think, maybe it's the CTime. It's the only table, that contains this datafield. I will try to replace CTime with long and write some conversion-members.
Juergen
|
|
|
|
|
e-DJ wrote: I think, maybe it's the CTime.
I doubt it. I've had several record sets with CTime member variables. They update fine.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Yes,
I have another table without CTime and this table is also opened read-only One I haven't tried before.
I wrote a small application, that does nothing else, except connecting to my SQl-Server database and appending a record. And it worked. The record was appended, but when I tried to delete this record again, SQL-Server told me something about relations and deleting more than one line. So I have some garbage-data in my database, that can not be deleted again. I have to drop the complete table.
I think I quit it and try to share my access-file on a fileserver. It's awful, but I don't know, why SQL-Server opens some of my tables read-only. I need this application by the end of the month and I thought, well it runs on access, now I migrate access to SQL-Server and everything is fine. Bad luck, haven't thought about Microsoft
By the way, when reading from the access-file it is much faster than reading from SQL-Server, which is really strange.
Juergen
|
|
|
|
|
Strange things happen.
I created my SQL-Server database completely new and suddenly my tables work now.
At least most of them. Two tables are still readonly, but the rest is working. So I think, it's not a problem of my application, it's a problem of SQl-Server
Juergen
|
|
|
|
|
I'm going completely nuts.
I changed my connection type from dynaset to snapshot and suddenly it works. Everything works as expected and even faster, too.
Now I have to change my sources a little bit to support a snapshot connection and I am finished with my project.
Thanks for all your help
Juergen
|
|
|
|
|
For example
GetLastError()==ERROR_IO_PENDING
WSAGetLastError()==WSA_IO_PENDING
Which one should I use in socket programming?
|
|
|
|
|
followait wrote: Which one should I use in socket programming?
WSAGetLastError , since it is Windows Sockets 2 specific.
Maxwell Chen
|
|
|
|
|
followait wrote:
Which one should I use in socket programming?
Theoretically speaking, when using sockets, you should use the WSA calls. Practically speaking, they end up going to the same place (that is, WSAGetLastError simply returns the a call to GetLastError and the WSA values are pretty much the same as their normal win32 API equivalents). You should NOT assume that will always be the case, however.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Do you mean, practically, I could use either one?
But the two MACRO for error no. is differenct.
|
|
|
|
|
followait wrote: Do you mean, practically, I could use either one?
Yes, practically, you could use either one (at the moment). However, if Microsoft decides to change the behavior of WSAGetLastError, you'd be up the creek if you used GetLastError instead. While there isn't a high probability of that, in practice you should use WSAGetLastError when dealing with sockets. Not to mention that it makes your code consistent with the other socket calls (for someone else trying to read your code).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I see
win32
#define WSA_IO_PENDING (ERROR_IO_PENDING)
win16
#define wSA_IO_PENDING (WSAEWOULDBLOCK)
|
|
|
|
|
I m using list class in one of my classes in a project but getting this compile time error.
Compiling...
IvrNodeManager.cpp
f:\laeeq\ivr\ivr project\advivr\ivractions.h(35) : error C2143: syntax error : missing ';' before '<'
f:\laeeq\ivr\ivr project\advivr\ivractions.h(35) : error C2501: 'list' : missing storage-class or type specifiers
f:\laeeq\ivr\ivr project\advivr\ivractions.h(35) : error C2059: syntax error : '<'
f:\laeeq\ivr\ivr project\advivr\ivractions.h(35) : error C2238: unexpected token(s) preceding ';'
f:\laeeq\ivr\ivr project\advivr\ivrnodemanager.cpp(14) : error C2065: 'list' : undeclared identifier
f:\laeeq\ivr\ivr project\advivr\ivrnodemanager.cpp(14) : error C2059: syntax error : '>'
f:\laeeq\ivr\ivr project\advivr\ivrnodemanager.cpp(14) : error C2039: 'iterator' : is not a member of '`global namespace''
f:\laeeq\ivr\ivr project\advivr\ivrnodemanager.cpp(15) : error C2065: 'listIterat' : undeclared identifier
f:\laeeq\ivr\ivr project\advivr\ivrnodemanager.cpp(15) : error C2039: 'end' : is not a member of 'CList<class civraction,class="" civraction="" &="">'
f:\laeeq\ivr\ivr project\advivr\ivrnodemanager.cpp(15) : fatal error C1903: unable to recover from previous error(s); stopping compilation
here is the code of class CIVRNodeManager which is in ivrnodemanager.h
//////////////////////// ivrnodemanager.h ///////////////////
#include <list>#include "afxtempl.h"
#include <list>#include "DigitActions.h"
#include <string>
using namespace std;
class CIVRAction
{
public:
CIVRAction();
~CIVRAction();
private:
CString m_strName;
CString m_strType;
CString m_iID;
CString m_strActionIDOnSuccess;
CString m_strActionIDOnFaile;
CString m_strActionIDOnTimeout;
CString m_strActionIDOnMaxRetries;
public:
list <cdigitactions*> m_lstDigitActions;
////////////////////////////////////////////////
CDigitActions is a class which is already compiled
Cyber Friend
|
|
|
|
|
Some < and > are missing. Would you please modify the post by check the "Ignore HTML tags ..." ?
Maxwell Chen
|
|
|
|
|
sorry actually this line is causing problem
list <cdigitactions*> m_lstDigitActions;
I will be thankful if any one helps.
Cyber Friend
|
|
|
|
|
sorry this line is causing problems
list <CDigitActions*> m_lstDigitActions;
Cyber Friend
|
|
|
|
|
Cyber Friend wrote: list <cdigitactions*> m_lstDigitActions;
Can you add one include:
#include "stdafx.h" And move #include <list> below the line #include "stdafx.h" ?
Maxwell Chen
|
|
|
|
|
Yes i have done that but errors r still there
Cyber Friend
|
|
|
|
|
Can you please post the content of code again by ignoring HTML tags for more clearer about < and > ?! Thanks!
Maxwell Chen
|
|
|
|
|
Here is updated code after addition of stdafx.h
///////////////// //////////////////////////////////////////////////
#include "stdafx.h"
#include <list>#include "afxtempl.h"
#include "DigitActions.h"
#include <string>
using namespace std;
class CIVRAction
{
public:
CIVRAction();
~CIVRAction();
private:
CString m_strName;
CString m_strType;
CString m_iID;
CString m_strActionIDOnSuccess;
CString m_strActionIDOnFaile;
CString m_strActionIDOnTimeout;
CString m_strActionIDOnMaxRetries;
public:
list <CDigitActions*> m_lstDigitActions;
Cyber Friend
|
|
|
|