![]() |
|
#1
|
|||
|
|||
Help! undeclared identifier errorHello. I am a newbie to VC++.Net, having a total of 4 days experience... I have a VB6 and SQL Server background.
I am trying to create an instance of SqlXmlCommand, but get a compile error 'undeclared identifier'. I have added the 'Microsoft.Data.SqlXml' dll to my references, and use the following code: TCHAR szConnectionString[500]; _tcscat(szConnectionString, "Provider=SQLOLEDB;Data Source="); _tcscat(szConnectionString, szServer); _tcscat(szConnectionString, "\\NetSDK"); _tcscat(szConnectionString, ";Initial Catalog="); _tcscat(szConnectionString, szDatabase); _tcscat(szConnectionString, ";Trusted_Connection=yes;"); SqlXmlCommand* spCMD = new SqlXmlCommand(szConnectionString)); When I type 'Microsoft.Data.SqlXml::' I get SqlXmlCommand listed, but when using '::', I get this error: ": error C2882: 'Microsoft' : illegal use of namespace identifier in expression" I know I am missing something really stupid, but all the documentation and sample code for SqlXmlCommand is in C# and VB. I am using a SQL Server extended stored procedure project. I intend to call the extended stored procedure from SQL Server, passing the name of a XML Template with embedded SQL. The DLL will use SqlXmlCommand to prepare a XML document which I'll save as a XML file. If you can help, I'd be very grateful! |
|
#2
|
||||
|
||||
|
The answer it is what it is probably seems stupid
http://msdn.microsoft.com/library/de...err28xx_58.asp Quote:
What do you mean by using "::"? Please show the code where you use this... If I missunderstood the question, sorry... Regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
::Thanks for the prompt reply!
I use: Microsoft.Data.SqlXml::SqlXmlCommand* spCMD = new Microsoft.Data.SqlXml::SqlXmlCommand(szConnectionS tring)); and get these compile errors: error C2882: 'Microsoft' : illegal use of namespace identifier in expression error C2228: left of '.Data' must have class/struct/union type error C2653: 'SqlXml' : is not a class or namespace name error C2228: left of '.SqlXmlCommand' must have class/struct/union type |
|
#4
|
||||
|
||||
|
Quote:
Hmm, I think you might have a problem with the TCHAR... I suppose since you use managed extensions, it expects you to only have data on the managed heap. I'm not sure though... Try using something like: CPP / C++ / C Code:
Hope this is right, I don't have .NET at work. This will ensure using managed strings; please let me know if it solves your problem. Regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#5
|
|||
|
|||
error on _tcscatI now get an error on:
_tcscat(szConnectionString, "Provider=SQLOLEDB;Data Source="); _tcscat(szConnectionString, szServer); _tcscat(szConnectionString, "\\NetSDK"); _tcscat(szConnectionString, ";Initial Catalog="); _tcscat(szConnectionString, szDatabase); _tcscat(szConnectionString, ";Trusted_Connection=yes;"); Could you suggest replacement code now what szConnectionString is a string not TCHAR? Wayne |
|
#6
|
|||
|
|||
|
Am using String::Concat in place of _tcscat.
Still get the same 'undeclared identifier' compile error, though... |
|
#7
|
||||
|
||||
|
Quote:
Oh, of course you can't use the same code... Like I said, I don't have .NET on my computer, but it probably is something like: CPP / C++ / C Code:
Although I'm not sure about concatanation between strings in .NET - you might get something about adding 2 pointers - it works in Java. In case this doesn't work, try doing it at allocation (new(stuff I wrote)). Anyway, once you manage the concat, it should work.... Ohh, what about String::Copy? You might want to give that a try too. Sorry, I don't even have VS 6 right now - just try a little variation on these things, I'm sure you can manage. Regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#8
|
||||
|
||||
|
Quote:
I didn't see this reply... I'm pretty sure the site has some problems with the refresh. It might be my connection though.... Quote:
If so....do you get the other errors as well? Try including the namespace Microsoft.Data.SqlXml and then just use SqlXmlCommand by itself. Also, make sure your project has "Managed Extensions" enabled. Don't ask me where you check this, like I said Quote:
Sorry. __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#9
|
|||
|
|||
WorksThanks!!!!
Used: CPP / C++ / C Code:
The main source of the problem was that VC++ didn't like the full stops in Microsoft.Data.SqlXml, it wanted :: in place of the full stops! Thanks for the help! Now I must just see how I can convert my TCHAR variables to the strings you suggested I need to use. Last edited by LuciWiz : 06-Feb-2006 at 07:24.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
Recent GIDBlog
Toyota - 2008 August Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Operator Overloading: << | aaroncohn | C++ Forum | 36 | 07-Dec-2004 19:22 |
| Including Maps and strings?? | maddie | C++ Forum | 17 | 05-Jul-2004 06:25 |
| link error? | pablowablo | C++ Forum | 14 | 19-Jun-2004 10:00 |
| OpenGL always reports error | mvt | OpenGL Programming | 2 | 04-Jun-2004 06:42 |
| some I/O problems...again | cameron | C++ Forum | 3 | 03-Mar-2004 21:39 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The