|
Hi guys,
I am trying to write into xls file. This part is ok.
problem occur while reading from xls file.
error shows as follows :
syntax error in query expression field_2 by demo
code I use for writing into xls file is as follows.
void CWrite_read_xlsDlg::OnButton1()
{
CDatabase database;
CString sDriver = "MICROSOFT EXCEL DRIVER (*.XLS)";
CString sExcelFile = "c:\\kdr.xls";
CString sSql;
TRY
{
sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s",
sDriver, sExcelFile, sExcelFile);
// create database i.e excel sheet
if( database.OpenEx(sSql,CDatabase::noOdbcDialog) )
{
// create table structure
sSql = "CREATE TABLE demo (Name TEXT,Address TEXT)";
database.ExecuteSQL(sSql);
// insert data into table i.e excel sheet
sSql = "INSERT INTO demo (Name,Address) VALUES ('Nilesh','Pune')";
database.ExecuteSQL(sSql);
sSql = "INSERT INTO demo (Name,Address) VALUES ('akash','Mumbai')";
database.ExecuteSQL(sSql);
sSql = "INSERT INTO demo (Name,Address) VALUES ('ajit','thane')";
database.ExecuteSQL(sSql);
sSql = "INSERT INTO demo (Name,Address) VALUES ('aaniket','Nashik')";
database.ExecuteSQL(sSql);
}
// close database
database.Close();
}
CATCH_ALL(e)
{
TRACE1("Driver not installed: %s",sDriver);
}
END_CATCH_ALL;
}
code I use for reading data from xls file
void CWrite_read_xlsDlg::OnButton2()
{
CDatabase database;
CString sSql;
CString Name, Address;
CString sDriver;
CString sDsn; // register datasource in ODBC database manager
CString sExcelFile = "c:\\kdr.xls";
m_cList.ResetContent();
sDriver = GetExcelDriver();
if(sDriver.IsEmpty())
{
AfxMessageBox(" No Excel ODBC driver found ");
}
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sExcelFile);
TRY
{
database.Open(NULL,false,false,sDsn);
//A CRecordset object represents a set of records selected from a data source.
//Known as recordsets
CRecordset recset(&database);
sSql = "SELECT field_1,field_2"
"FROM demo "
"ORDER BY field_1";
// sSql = "SELECT * FROM demo";
// sSql = "INSERT INTO demo (Name,Address) VALUES ('Nilesh','Pune')";
//"ORDER BY Name";
recset.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);
while(!recset.IsEOF() )
{
recset.GetFieldValue("field_1",Name);
recset.GetFieldValue("field_2",Address);
m_cList.AddString(Name + " --> "+Address );
// m_cList.AddString(Name);
recset.MoveNext();
}
database.Close();
}
CATCH(CDBException, e)
{
AfxMessageBox(" Database error : "+e->m_strError);
}
END_CATCH;
}
call GetExcelDriver().implementation of GetExcelDriver()is written separately.
Read data and dispay is occur when I click on button.
kindly give me a reply where I am wrong.
Refards
kedar
Girish
Software Developer
|
|
|
|
|
hi all i need to set the icon and run application of my new file format like *.eee
i am using VC++. i need some registry add application and i also need the problem solution
thanks
regards
sasikumar
|
|
|
|
|
Hi sasikumarselvarajan ,
Do you want to create eee instead exe?
|
|
|
|
|
First you don't need an extra application to register a file type.
Second you have already replied to a topic where the answer was given right here[^].
Third do some research before asking for answers.
|
|
|
|
|
hello,
can anybody please tell me, how can I make a installer/ setup ( self installing cd) with the executable compiled in VC++ ?The operating system is WINDOWS-2000.
I want to make a package with the final executable.
Please reply
thanks
|
|
|
|
|
You can use a setup creating program. I use Inno Setup[^].
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Inno Setup is great, and so easy to use, I would also recomend this
|
|
|
|
|
rajeevktripathi wrote: I want to make a package with the final executable.
yeap INNOSETUP is one finest free installer available in market if you are developing a simpler installer, otherwise you have to learn pascal type scripting to make complex installation program using same! just a warning
|
|
|
|
|
Hi,
I've used recordsets,I need to retrieve many records say two,so I tried to use while(!mp=ISEOF())
{
m_name1=mp->m_name
UpdateData(false)
}
Its getting strucked.If I use if(!mp=IsEof()),it gets me only one record
swapna_signsin
|
|
|
|
|
if(!mp==IsEof())
or
while(!mp==IsEof())
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
hi
sorry,I didn't use the code I specified but its,if(!mp->IsEof()),Ialso tried the code given,but that doesn't work.
need hlp
swapna_signsin
|
|
|
|
|
Sir when open my resource editor or when i click.
on any resource dialog i am getting a messagebox
informing .clw file is changed out the editor.
this messagebox is just coming continously.not allowing me
to do any thing pls help me what should i do in order to
avoid it.so that my application runs smoothly.
thank you
Fly Like An Eagle With MIGHTY POWER.
|
|
|
|
|
satishvarma_e wrote: Sir when open my resource editor or when i click.on any resource dialog i am getting a messagebox informing .clw file is changed out the editor.this messagebox is just coming continously.not allowing meto do any thing pls help me what should i do in order to avoid it.so that my application runs smoothl
delete you project_name.ncw,project_name.clw and project_nameaps file and restart your visual studio again. may be one of these files get corrupted!
|
|
|
|
|
I have a program that gets a set of 3 messages every second or so.
The message:
- hwnd is NULL (thread message, not window message)
- message is 49338 (0xc0ba)
- LPARAM, WPARAM change for each of the 3 messages
Messages between 0xc000 and 0xffff are string messages generated by RegisterWindowMessage().
I don't call RegisterWindowMessage, which leads me to believe either the debugger or another library (e.g. OpenGL) has created the message.
How can i find who called RegisterWindowMessage to get the message id 0xc0ba ?
And/or, how can i find what string was passed to RegisterWindowMessage ?
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I don't think you can reverse the RegisterWindowMessage() function, but if you have Spy++ installed (it's part of the Visual Studio installation, Tools->Spy++) you can use it to find out which application is sending the messages. Run Spy++, use the Find Window dialog to pick your root window, choose the 'show messages' option and then hit OK. A window will pop up showing all the messages your application is receiving, and you can then find the offending messages.
You usually see lines in the Spy++ application that look like:
000D072C S message:0x1065 (User-defined:WM_USER+3173) wParam:00000000 lParam:00000000
000D072C R message:0x1065 (User-defined:WM_USER+3173) lResult:00000000
If you double-click on the 'S' line you'll see information about the sender of the message. Going to the 'Process' tab will then allow you to find out who's sending the message.
In my experience the usual culprits for sending out lots of messages like this are media players which broadcast information about where they are in the song so that third-party plugins can show song information etc.
I know this isn't quite an answer to your original question, but I hope it's useful!
Matt Godbolt
Engineer, ProFactor Software
StyleManager project
|
|
|
|
|
Matt, thanks for the reply, but ...
I've been using Spy++ for years, it was the first thing i tried.
Unfortunately Spy++ doesn't seem to:
- show thread messages, only windows messages (i.e. message must have hwnd set)
- show information about the sender, nor do i see how it could, that information isn't present in a message structure
- doesn't seem to catch any messages for x64 apps (Spy++ is a 32bit app, so i can understand that - kinda)
I'm running Win2003 R2 x64, VS2005, debugging an app i can compile as 32 or 64bit.
Running Spy++ on the 32bit build show messages sent to windows, but doesn't catch the ones i'm looking for. I know the messages are being sent/caught because i have the debugger open at the same time and have a breakpoint set to catch the messages.
Oh well, i'll keep looking.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Blast! Sorry to preach to the choir there then! Good luck; and if you do find out a way to turn messages back into their registered strings, be sure to post back - I'd love to know!
Matt Godbolt
Engineer, ProFactor Software
StyleManager project
|
|
|
|
|
Matt Godbolt wrote: if you do find out a way to turn messages back into their registered strings, be sure to post back - I'd love to know
Yes, well i originally thought they would be ATOM's ... i think they used to be.
To bad neither GetAtomName, nor GlobalGetAtomName find them now.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi all
I want to enumerate the list of most frequently used programs from start menu links, thier icons and related things.
As R-Wipe&Clean shows the list of MFU Registry Traces.
Please guide me.
Thanks
|
|
|
|
|
Hi rajeevktripathi,
I'm not sure this good way but maybe it is some helpful to you
DWORD dwR,DataSize;
HKEY hKey1;
TCHAR sz[MAX_PATH];
dwR = RegOpenKey (HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"),&hKey1);
CStringArray m_Array;
CString str;
TCHAR m_Value[256];
DWORD m_dValue = 256;
DWORD m_Data;
for(int i=0;i<15;i++)//example
{
m_dValue=256;
m_Data = 256;
RegEnumValue (hKey1,
i,
m_Value,
&m_dValue,
NULL,
NULL,
NULL,
&m_Data);
m_Array.Add(m_Value);
}
for(int i=0;i
|
|
|
|
|
If you mean the pin list on the XP start menu, there is no programmatic access to this list, by design. You may be able to fool with it by grovelling in the registry, but that may break in future revs of the OS.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi
Thans for your replies
Michael Dunn, I wanna exactly what you said, Infact I need it in a wiping tool so it is there any way to show these MFU programs.
Please reply
Thanks
|
|
|
|
|
hi all
I want to check for a valid IP address.the code is as follows
CString strFileName=_T("C:\\Windows\\System32\\Ping.exe");
CString strIpaddress=_T("10.37.8.4");
if(!(int)ShellExecute(NULL,_T("open"), strFileName,strIpaddress,NULL,SW_SHOW) == ERROR_FILE_NOT_FOUND)
{
AfxMessageBox(_T("Successful"));
}
else
{
AfxMessageBox(_T("Ping Failed"));
}
The Problem is that when i execute this it opens the Ping.exe and it checks for valid address but the message box "Successful" is not displayed..instead "Ping Failed" is displayed even after executing Ping exe successfully.
What could be the problem??
Are there any other ways to check for Valid IP address(i.e URL name) like gethostbyname()??
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
-- modified at 6:17 Saturday 8th April, 2006
|
|
|
|
|
r u drunk?
do u read ur code:
ShellExecute()==ERROR_FILE_NOT_FOUND
?
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
includeh10 wrote: ShellExecute()==ERROR_FILE_NOT_FOUND
for your info ShellExecute returns ERROR_FILE_NOT_FOUND if the specified file is not found.i typecasted into int though i didn't store into the HINSTANCE....
still waiting for the reply....
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|