|
Implement SQLXML Bulk Load using C++Implement SQLXML Bulk Load using C++
01 Dec 2005
Saint Paul, Minnesota
macgowan@pobox.com
Hi ...
I am trying to bulk load xml into sql server. This seems to be a relativly easy thing to do using the SQLXML COM Component. I am having trouble finding documentation on the SQLXML COM Object model. Also I have found samples in C# and VB ... I need my implementation to be using C++. If you have any sample code or a like you can send me to that would be create.
A good example of the type of doc that I am looking for is the object model for the MSXML COM Component
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceappservices5/html/wce50grfxmldomobjectsinterfaces.asp
Is there such documentation for the SQLXML COM
Below are the links I have used to date:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_sqlxml.asp
http://www.dbazine.com/sql/sql-articles/cook3
http://www.perfectxml.com/sqlxml.asp
Some code:
The code below uses the IXMLDOMDocument2Ptr interface and then trys to
use the SQLXML using the SQLXMLOLEDB Provider. Again, I need some doc
or samples on how to use the SQLXML COM Interfaces or the
SQLXMLOLEDB Provider in C++.
The code will fail on the following line
pCmd.CreateInstance(__uuidof(SQLXMLBulkLoad));
void CTestApp::OnTestMsXmlTest()<br />
{<br />
_ConnectionPtr pConnection = NULL;<br />
<br />
try<br />
{<br />
<br />
CoInitialize(NULL);<br />
IXMLDOMDocument2Ptr pXMLDoc = NULL;<br />
TCHAR szHTTPURL[MAX_PATH] = {0};<br />
<br />
_tcscpy(szHTTPURL, "http://www.buckeyetraffic.org/rwis/data/siteDetailS.xml");<br />
_variant_t varLoadResult((bool)FALSE);<br />
<br />
pXMLDoc.CreateInstance("Msxml2.DOMDocument.4.0");<br />
<br />
pXMLDoc->async = false;<br />
<br />
pXMLDoc->setProperty("ServerHTTPRequest", VARIANT_TRUE);<br />
<br />
varLoadResult = pXMLDoc->load(szHTTPURL);<br />
<br />
csResult =::SysAllocString(pXMLDoc->xml);<br />
<br />
<br />
<br />
pConnection.CreateInstance(__uuidof(Connection));<br />
<br />
CString csProvider("sqloledb");<br />
CString csDataSource("SQLTEST1");<br />
CString csInitialCatalog("TestData");<br />
CString csUserId("bill");<br />
CString csPassword("bluerayon");<br />
<br />
csConnect.Format("Provider='%s';Data Source='%s';",<br />
csProvider,<br />
csDataSource);<br />
csTemp.Format("Initial Catalog='%s';",<br />
csInitialCatalog);<br />
csConnect += csTemp;<br />
csTemp.Format("User Id=%s;Password=%s",<br />
csUserId,<br />
csPassword);<br />
csConnect += csTemp;<br />
<br />
bstrConnect = csConnect.AllocSysString();<br />
<br />
pView->WriteLog("Open ADO Connection.");<br />
<br />
pConnection->Open(bstrConnect,"","",adConnectUnspecified);<br />
<br />
_CommandPtr pCmd = NULL;<br />
<br />
pCmd.CreateInstance(__uuidof(Command));<br />
<br />
pCmd->ActiveConnection = pConnection;<br />
pCmd->PutPrepared(true);<br />
<br />
pCmd->Execute("SampleSchema.xml", "SampleXMLData.xml", adExecuteStream);<br />
<br />
}<br />
catch(...)<br />
{<br />
}<br />
<br />
CoUninitialize();<br />
return;<br />
}<br />
|
|
|
|
|
I need to implement a function to read application event logs in realtime. I have done this for our Unix server in Perl, but do not have the option of installing Perl on our Win32 production servers.
I have scoured (literally for days) the internet looking for any information on the best way to do this in C++ but haven't found anything! Any assistance or direction is greatly appreciated.
What I need to do is read these event logs and then send alerts or trigger other functions based on specific events. The log files are updated 10-100 times a minute depending on how many users are connected to the server so I need to continue monitoring the log even if I fork out to respond to event01. Make sense?
Thank you!
--Kenny
|
|
|
|
|
Sounds like you want to create an Event object ( see CreateEvent()[^]) wait on it in on place (thread) and then signal it from another when the log write occurs.
You can look into NT's event logging API's but I don't know if there are any performance issues for what you're intendending.
You can create teh event with a name, so that more than one process can wait on it.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
That definately seems to take care of the second part of my problem. Thank you!
Now do you have any advice on the most effecient way to read a log file that is being updated almost constantly?
|
|
|
|
|
Well just off the top of my head, if you're worried about access speed/io to the file, you could create a memory mapped file and then use that - then one process can write, another can read, without having to contantly open/close the file all the time.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
This is a bit too much C++ as I am mostly a Perl/PHP developer. I was hoping for something that I could do with simple file I/O. =)
I will look into it however.
Thanks!
|
|
|
|
|
Well then you could just open the file, and read from the end of it. Maybe keep track of the file size from the previous open, and compare to it's current size, and then read in the difference from the end. That's slower, and less complex, but makes heavier duty use of disk IO. Don't know how big a deal that is for you.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Kenny0323 wrote: This is a bit too much C++...
Actually, memory mapped files have nothing to do with C++. One thread/process will need to call CreateFileForMapping() (all others will need to call CreateFile() ). Call CreateFileMapping() , then use the pointer returned from calling MapViewOfFile() .
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Will NotifyChangeEventLog() help?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I looked into this, but this seems tailored to logs that use the same format (and actually write to) the windows event logs. Which our system does not.
Thank you, though.
*** I guess I should have been more clear. These are *not* standard Windows App Event Logs, they are flat text .LOG files.
|
|
|
|
|
Kenny0323 wrote: I looked into this, but this seems tailored to logs that use the same format (and actually write to) the windows event logs.
When you said "application event logs", that only means one thing to me.
Kenny0323 wrote: These are *not* standard Windows App Event Logs, they are flat text .LOG files.
You'll need to make sure that read and write operations are synchronized. Otherwise, one could preempt the other and you'd have a big mess to clean up.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
How to change color of text and background on the About dialog ?
|
|
|
|
|
Is there a method that, when you select something from a drop down menu, will automaticly go to another dialog edit control box? Like when you hit tab, so that the number, or whatever is inside, is highlighted and ready to be chaged. It seems there should be, and i dont think im wording it right in my google searches.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Why not just call SetFocus() in the menu handler to set the focus to the edit control? You might need to do a SET SEL as well.
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison
Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
Yes, setsel was what i was looking for, thank you.
"There are 10 types of people, those who understand binary, and those who don't."
- Somebody, not me.
|
|
|
|
|
Hi,
I developed a thumbnail viewer using doc / view architecture and GDI+. I have done the rotate, flip options, but when we choose or click any thumbnail image, I want to draw the focus rectangle around the image instead of bluecolor shadow selection. Can u help me ...... if it is possible send a sample code.
Thanking you.
Regards,
Inbakumar.G
-- modified at 9:37 Thursday 1st December, 2005
|
|
|
|
|
Greetings:
I am trying to create one of those dialog boxes that have an "expand and contract" feature. I'm sure you have all seen them: The box has a smaller "fixed" segment, say, at the top, but there is a control, like a button that says "More >>" that causes it to expand at the bottom and reveal additional controls and options.
I think I understand that I need to create TWO dialog resource templates, one representing the fixed top portion and a second that is layed out at the top identical to the first dialog but larger at the bottom with the extra controls. Then, when the "More >>" button is pushed, somehow, I swap the old resource template for the new one.
Its the "somehow" part that has me stumped. I have two questions:
1. How do I keep the dialog open while I swapp templates? (Or can I? Is this done some other way?)
2. How do I do this trick while keeping the fixed part of the dialog positioned on the screen? In otherwords, I don't want the the new, larger, dialog window trying to re-center itself. I want the top part to stay put and the swap operation to appear as though the dialog has literally expanded at the bottom.
If it turns out that I have to essentially close the old dialog and re-open it with the larger template, then I would like to preserve the illusion that the original dialog is simply expanding to revela more controls.
I guess that is a pretty loaded request but any assistance would be greatly appreciated.
Thank you,
Mark
|
|
|
|
|
You can create a second dialog resource and attach a class to it. Create it as modeless, and a child of the main dialog. When user presses the more button, show it using ShowWindow(SW_SHOW); and position it correctly using SetWindowPos() etc. Similarly when button is pressed again, check if it is visible: m_ChildDialog.ShowWindow(! m_ChildDialog.IsWindowVisible());
Hope that helps.
this is this.
|
|
|
|
|
Hi Khan:
Is there anyway to do this and still keep the dialogs modal?
Also, what will happen if the user moves the new window? Won't the old window be revealed behind it?
Thanks for your help!
Mark
|
|
|
|
|
If you need to scroll the controls at the bottom into view, then create all the controls on the main dialog, and increase/decrease the height of the dialog in a loop using SetWindowPos() .
this is this.
|
|
|
|
|
I've done this by dinamically hiding\disabling set of controls + resize of the dialog itself. If your extra portion is in the middle, this would need some efforts to reposition other controls, but I have done this too before.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
|
Thanks Igor. I'll check these out.
Mark
|
|
|
|
|
What do you think if I implement my classes in .h files instead of dividing the declarations in .h files and the implementation in .cpp?
Is this a bad programming style or it will bother the compiler?
|
|
|
|
|
For me it seems strange,
I know that AppWizard makes the reverse for CAboutDlg of
a single/multidocument app
It inserts the declaration in .cpp before the implementation
I think it's better the usual way
|
|
|
|