Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kdd21
Starting Member
11 Posts |
Posted - 2005-12-16 : 14:25:07
|
This may be crossposted to some other forums out of sheer desperation...Been working in Visual Studio 2005 and got to the point where I needed to build a native program that interfaces with SQL Server via the bulk copy API. So, I d/l'ed SQL Server 2005, installed it and tried a simple example from MSDN from the bcp_bind documentation.Fails because it is unable to find "sqlfront.h." I search the web. Best suggestion I can find is to install the "Platform SDK" Installed that. Installed everything I could find from the SQL Server 2005 distribution CDs. "sqlfront.h" is not in "Visual Studio 8/VC/PlatformSDK/include or"VIsual Studio 8/VC/include", where I would have thought they might end up.Found a reference that indicated there may be some kind of SQL Server SDK, or "Microsoft SQL Server Programmers Toolkit" that I might need to download, but so far I've been unable to find one. Toolkit appears to be obsolete anyway. Other suggestions indicate it may be included in the Platform SDK, but I already tried that, no cigar...Did a search of the whole computer. It found a copy of sqlfront.h, one in "Microsoft Visual Studio/VC98/include"-- which is one from VS 6.0, as I also have VS 6.0 on this system as that is what our current development uses, we're trying to move some things to .NET, and that's the only one it found.. Can I just use the includes from VS 6.0? Are these the latest ones and that's why I've been unable to find ones for VS 2005? Did Platform SDK install it in the wrong tree? If so, how do I correct for that? Can VS 2005 link with the ssociated library files from VS 6.0? How are you*supposed* to get these darn files so the stupid example will compile?I'm on XP SP2 BTW, and in the MSDN developer program (msdn universal volume license), if that is of any relevance.Uninstalling VS 6.0 is not an option, that's what all our current development is using. Installing VS 2005 on another PC is not an option, I'm the only developer in this particular office and they aren't going to buy me a new PC to do this. Deciding NOT to transition to .NET and VS 2005 is an option however, and the one I'm currently giving the most serious consideration. Uninstalling VS 2005 and going to VS 2003 or something could be an option, but it would be nice to know if it would actually fix the problem. Reverting to an eariler SQL Server version could be an option as well, but again, it'd be nice to know that it would actually fix the problem.I also noted that doing searches for stuff on MSDN does not make it very clear WHICH version of whatever (VS, VC++, SQL Server, etc.) the information applies to. Often I would find pages and wonder if it applies to the .NET version or is leftover from some previous incarnation of the product and possibly no longer applies to the .NET version. Best I can tell, you can't restrict searches by product version (if I'm wrong, please enlighten me). What a nightmare-- I've just spent 2 days trying to get the simplest of example programs to compile a native program on VS 2005.Plenty of other people seem to have inquired aboutthe location of sqlfront.h though, I notice, yet so far I've not found a response that was helpful to me.Has ANYONE been able to compile a native VC++ program that talks to SQL Server on the 2005 versions of VS & SQL Server? Was it my mistake because I happened to choose to try the "latest" versions of these products just as they came out, and thought I could actually dosomething useful with them?If you've been able to make it work, where does your sqlfront.h file live on your system? Any idea how it got there?--Sync |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-12-16 : 15:19:34
|
Can I ask a silly question: WHY do you need to use the bulk copy API? What needs to be done, what is your goal/requirement? |
 |
|
kdd21
Starting Member
11 Posts |
Posted - 2005-12-16 : 20:58:47
|
Application is a data analysis system. It works by exporting data from a separate server (and different database) and then moving the export files to a PC system for analysis. This occurs over and over as various snapshots are analyzed. Analysis system uses SQL Server. Currently the process includes copying the host files across and running them thorugh several separate filtering programs, producing filtered and massaged files (one per database table) ready to be fed to the bcp command line utility. Process is currently rather slow-- am investigating merging the process into a single executable that does all the export file prep and bulk import in a single executable without rewriting intermediaries to disk to try to improve performance a bit...--Sync |
 |
|
kdd21
Starting Member
11 Posts |
Posted - 2005-12-19 : 17:06:33
|
Well, it appears the peice I need should be under "Program Files/Microsoft Sql Server/80/Tools/DevTools. Or perhaps "Program Files/Microsoft SQL Server/90/Tools/DevTools."I reinstalled SQL Server 2005 (developer edition) from scratch andchecked everything and there's no DevTools directory to be foundanywhere.Then I tried installing the .NET Framework SDK (already did thePlatform SDK) and am going to try the SQL Server Native Client piece,the Backward Compatibility components and the Management Objectscollection to see if perhaps it's in any of those. Anyone with any idea where you get the DevTools directory for SQL Server 2005, I'd sure like to know...--Sync |
 |
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2005-12-19 : 17:37:37
|
Is all this work really worth trying to find a work around to writing the BCP'd data to disk? I'm guessing that you are taking about a lot of data that is going to have to be written to memory really fast. Do you have that much memory?It sounds like you need to do some work in the BCP command to output the data like you need it instead of touching it after BCP spits it out.Michael<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda> |
 |
|
kdd21
Starting Member
11 Posts |
Posted - 2005-12-19 : 18:10:48
|
What I am hoping to do is to bulk copy the data TO the database as I'mreading it from transferred flat files and massaging it. Somethingpretty similar to the bcp_bind example here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dblibc/dbc_pdc09_4fac.aspbut with a "getdata" function that does some tweaking of the dataas it's reading it in. Should be pretty darn simple and shouldn't needa lot of memory, as you can call bcp_batch to have it update thedatabase every "n" rows-- in which case I wouldn't think it would becaching more than "n" rows in memory...In any event, just how hard should it be to compile that example programanyway? The includes I'm talking about are fundamental pieces of anyVC++ program that would directly interoperate with SQL Server, is itthat noone is doing that? Am I on completely uncharted waters here?I'd use VB, but the string handling I need to do is far easier ina C variant, and we've already done some testing and found that thestring objects and getline are too slow for the filtering we are doing--I had to resort to buffers and fread. Also, I already know VC++ as well(though V6.0), while VB is pretty alien at the moment. Plus, I got theimpression that both VB and C# are CLR only, you can't do native withthem, and neither support a fread() equivalent (sans strings/getline)-- or am I mistaken there?So,Tried installing the Feature Pack files I mentioned, all were alreadyinstalled except the Management Objects and that did not net me theincludes. Was going to revert to SQL Server 2003, then I realized thereis no 2003 (or at least, none available on the MSDN subscriber D/L's),and 2000 seems too old to use for new development. I'm now thinkingthat perhaps the Enterprise version might have what I'm looking for(though you'd really think include files would be on the *developerversion*)... I don't know how else to get the bcp_bind example tocompile at this point other than reverting all the way back to SQLServer 2000, and I really would rather NOT do that...--Sync--Sync |
 |
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2005-12-19 : 18:44:17
|
I've never ventured into any of the extended stored proc or directly calling SQL server API's myself.As far as .Net, there is Managed C++ in .Net. All the native stuff of VC++, with some of the .net managed stuff to go with it. I'm no expert at that either, but it's something to look into.Michael<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda> |
 |
|
kdd21
Starting Member
11 Posts |
Posted - 2005-12-19 : 19:00:19
|
I got the impression that Managed C++ is restricted to using only certaincapabilities, and low-level things like "fread" are not supported. I could easily be misinformed there though.HOWEVER, I DID FIND THE ANSWER:Looks like they changed the interface somewhat, and it wasn't easyto determine that-- the bcp_bind example was for SQL Server 2000,and it hasn't been updated for SQL Server 2005.Apparently, "sqlfront.h" and "sqldb.h" no longer exist. The old bulkcopy functions are now ODBC based and use the include "sqlncli.h" andan ODBC handle instead of a DBPROCESS structure. There was an articlein the books online entitled "Converting from DB Library to ODBC BulkCopy functions" that explains the difference, which I never foundbecause I didn't know about it and doesn't mention the differences inthe includes, which is what breaks when you try the example foundon the MSDN library (which is for SQL Server 2000).So, I'm going to work on converting the example to an ODBC versionbased on the articles I've found......--Sync--Sync |
 |
|
|
|
|
|
|