|
i have already seen this code this is simply picking up the folders which are exsisting there in the pst file my problem is that i want to read deleted items to (that r deleted from deleted items to).is there any type of check or flag bit which is placed infront of deleted folder.or its id is deleted
|
|
|
|
|
Can you use Outlook automation?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Can anybody here explain me wht this code is doing.Thanks
<br />
CDaoDatabase database;<br />
CDaoRecordset recordset(&database);<br />
CString lpszFile = "c:\\Database.mdb";<br />
database.Create(lpszFile);<br />
database.Open(lpszFile);<br />
CString SqlCmd = "CREATE TABLE MYTable.mdb (MarketNo VARCHAR(2),MarketName VARCHAR(8),Bid VARCHAR(10),Ask VARCHAR(10),MarketState VARCHAR(2))";<br />
database.Execute(SqlCmd);<br />
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM MyTable",0);<br />
database.Execute("INSERT INTO MyTable(MarketNo)");<br />
database.Execute("INSERT INTO MyTable(MarketName)");<br />
database.Execute("INSERT INTO MyTable(Bid)");<br />
database.Execute("INSERT INTO MyTable(Ask)");<br />
database.Execute("INSERT INTO MyTable(MarketState)");<br />
recordset.AddNew();<br />
recordset.SetFieldValue("MarketNo","a");<br />
recordset.SetFieldValue("MarketName",Market);<br />
recordset.SetFieldValue("Bid","b");<br />
recordset.SetFieldValue("Ask","c");<br />
recordset.SetFieldValue("MarketState","d");<br />
recordset.Update();<br />
recordset.MoveNext();<br />
recordset.AddNew();<br />
|
|
|
|
|
It seems that it open a access database and create a table with 5 cols and then read all records of MyTable and insert datas to these cols
|
|
|
|
|
i also think so..then why it is not creating database table with 5 col....and inserting data in that...do you have any idea.....
|
|
|
|
|
And when you create your database why use open and also MoveNext you dont have any records except one
|
|
|
|
|
i also think so..then why it is not creating database table with 5 col....and inserting data in that...do you have any idea.....or can you say hoe to c mytable
|
|
|
|
|
CDaoDatabase database;
CDaoRecordset recordset(&database);
CString lpszFile = "c:\\Database2.mdb";
database.Create(lpszFile);
//database.Open(lpszFile);
CString SqlCmd = "CREATE TABLE MYTable (MarketNo VARCHAR(2),MarketName VARCHAR(8),Bid VARCHAR(10),Ask VARCHAR(10),MarketState VARCHAR(2))";
database.Execute(SqlCmd);
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM MyTable",0);
database.Execute("INSERT INTO MyTable values('a','Market','b','c','d')");
//database.Execute("INSERT INTO MyTable(MarketName)");
//database.Execute("INSERT INTO MyTable(Bid)");
//database.Execute("INSERT INTO MyTable(Ask)");
//database.Execute("INSERT INTO MyTable(MarketState)");
recordset.AddNew();
recordset.SetFieldValue("MarketNo","2a");
recordset.SetFieldValue("MarketName","2Market");
recordset.SetFieldValue("Bid","2b");
recordset.SetFieldValue("Ask","2c");
recordset.SetFieldValue("MarketState","2d");
recordset.Update();
//recordset.MoveNext();
recordset.AddNew();
|
|
|
|
|
abrakadbra wrote: CString SqlCmd = "CREATE TABLE MYTable.mdb (MarketNo VARCHAR(2),MarketName VARCHAR(8),Bid VARCHAR(10),Ask VARCHAR(10),MarketState VARCHAR(2))";
Try removing the .mdb from your create table statement.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Not sure exactly what your're trying to do, but your insert into statements don't look right.
To add records, you can either use insert into statements or recordset's addnew/update, but you don't need to do both.
database.Execute( "INSERT INTO MyTable(MarketNo, MarketName, Bid, Ask, MarketState) VALUES('1', 'myname', '123', '150', 'A')" );
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
ok...but i am not able to c mytable..it is not creating the table..why..
|
|
|
|
|
You might have more luck in the Database Forum http://www.codeproject.com/script/comments/forums.asp?forumid=1725[^], but I don't think Access understands the same column types as SQL (i.e. you might need to change the varchar() to Text or something).
Do you have Access installed? Try creating your database in Access, and then maybe you can figure out the correct create table statement.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Why not wrap this code in a TRY /CATCH block to see why it is failing?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I seem to remember that you need to register the .mdb (forgot how to do it exactly), but I don't think you are going to have any luck until you register the database with Access. Or have things changed since my last foray into DBs about 5 years ago?
John P.
|
|
|
|
|
where can i get sample programs for serial communication using MFC?
|
|
|
|
|
|
|
Sometimes, while allocating memory in my programs, I get NULL in responce to call of new operator.
Sometimes, when I execute following pair of statements, I get Heap Error.
TCHAR * szText = new TCHAR[iLen * 7] ;
//... Some Code
delete [] szText ; // Causes heap error
Where and what I might be doing wrong?
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
What is the value of iLen ? And what is the code missing between these two lines. You don't provide any valuable information for us to help you...
|
|
|
|
|
You are right, not enough information:
Value of iLen is > 0 < 200. Moreover, between the lines, we are just calling string manipulation functions like strlen, strcpy etc. But when the delete []szText is executed, heap corruption message follows....
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
Can you post the exact code ? We cannot help if you don't provide meaningfull informations.
|
|
|
|
|
Polite Programmer wrote: between the lines, we are just calling string manipulation functions like strlen, strcpy etc.
What if these are omitted? Does the problem still exist? If not, it could be that you are writing outside of the allocated memory.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Polite Programmer wrote: I get NULL in responce to call of new operator.
Is this the problem?
Also try to use Safe String APIs instead of strcpy etc
S o h a i l K a d i w a l a
To Err Is Human; to Debug, Divine
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Here is the full code, Comments starting with NOTE are the erroroneous...
<br />
#include <windows.h><br />
#include <tchar.h><br />
#include <stdio.h><br />
<br />
#include "resource.h"<br />
<br />
#include "convert.h"<br />
<br />
HWND hwndNextClipboardVierwer ;<br />
char * szInPageData ;<br />
HFONT hFont ;<br />
<br />
<br />
<br />
<br />
void DumpHex(TCHAR * szText, HWND hDlg)<br />
{<br />
int iLen = _tcsclen(szText) ;<br />
TCHAR szBuffer[10] ;<br />
<br />
<br />
TCHAR * szHexDump = new TCHAR[iLen * 7] ;<br />
<br />
ZeroMemory(szHexDump, iLen * 7) ;<br />
<br />
for(int i = 0 ; i < iLen ; i++)<br />
{<br />
wsprintf(szBuffer, _T("0x%X, "), szText[i]) ;<br />
_tcscat(szHexDump, szBuffer) ;<br />
}<br />
<br />
SetDlgItemText(hDlg, IDC_EDIT_UNIHEX, szHexDump) ;<br />
<br />
<br />
delete [] szHexDump ;<br />
}<br />
<br />
BOOL CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)<br />
{<br />
HANDLE hMemory = NULL;<br />
TCHAR * szUnicodeText = NULL ;<br />
char * lptstr = NULL ;<br />
int iLen = NULL ;<br />
<br />
switch(msg)<br />
{<br />
case WM_INITDIALOG:<br />
<br />
hwndNextClipboardVierwer = SetClipboardViewer(hWnd) ;<br />
hFont = CreateFont( 80,<br />
80,<br />
0,<br />
0,<br />
0,<br />
0,<br />
0,<br />
0,<br />
0,<br />
0,<br />
0,<br />
0,<br />
0,<br />
_T("Pak Nastaleeq")) ;<br />
SendDlgItemMessage(hWnd, IDC_EDIT_UNICODE, WM_SETFONT, (WPARAM) hFont, TRUE) ;<br />
return FALSE ;<br />
<br />
case WM_DRAWCLIPBOARD:<br />
<br />
if(OpenClipboard(hWnd))<br />
{<br />
hMemory = GetClipboardData(CF_TEXT) ;<br />
lptstr = (char *) GlobalLock(hMemory) ;<br />
<br />
if(hMemory == NULL || lptstr == NULL)<br />
{<br />
CloseClipboard() ;<br />
return FALSE ;<br />
}<br />
<br />
iLen = strlen(lptstr) ;<br />
szInPageData = new char[iLen + 1] ;<br />
szUnicodeText = new TCHAR[(iLen / 2) + (iLen / 100) * 10] ;<br />
strcpy(szInPageData, lptstr) ;<br />
GlobalUnlock(hMemory) ;<br />
<br />
SendMessage(hwndNextClipboardVierwer, msg, wParam, lParam) ;<br />
ConvertInPageToUncode(szInPageData, iLen, szUnicodeText) ;<br />
DumpHex(szUnicodeText, hWnd) ;<br />
SetDlgItemText(hWnd, IDC_EDIT_UNICODE, szUnicodeText) ;<br />
<br />
delete [] szInPageData ;<br />
<br />
delete [] szUnicodeText ;<br />
<br />
<br />
}<br />
<br />
<br />
return TRUE ;<br />
<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam))<br />
{<br />
case IDOK:<br />
EndDialog(hWnd, 1) ;<br />
break ;<br />
case IDCANCEL:<br />
EndDialog(hWnd, 0) ;<br />
break ;<br />
<br />
}<br />
return TRUE ;<br />
<br />
case WM_DESTROY:<br />
ChangeClipboardChain(hWnd, hwndNextClipboardVierwer) ;<br />
return TRUE ;<br />
}<br />
<br />
return FALSE ;<br />
}<br />
<br />
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPTSTR lpCmdLine, int nCmdShow)<br />
{<br />
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc) ;<br />
return 0 ;<br />
}
Polite Programmer
More Object Oriented then C#
|
|
|
|
|
Polite Programmer wrote: void DumpHex(TCHAR * szText, HWND hDlg)
{
int iLen = _tcsclen(szText) ;
TCHAR szBuffer[10] ;
/*NOTE: This call fails i.e. returns NULL (even iLen is > 0)*/
TCHAR * szHexDump = new TCHAR[iLen * 7] ;
ZeroMemory(szHexDump, iLen * 7) ;
for(int i = 0 ; i < iLen ; i++)
{
wsprintf(szBuffer, _T("0x%X, "), szText[i]) ;
_tcscat(szHexDump, szBuffer) ;
}
/*NOTE: This Call generates Heap corruption message from CRT*/
delete [] szHexDump ;
}
This is the code snippet that you need to focus on. What is the value of ilen ? What does szBuffer look like each iteration of the loop? How are you verifying that szHexDump is big enough for iLen concatenations?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|