|
No, i want to do with win32 API's only
|
|
|
|
|
OK, then you need to ask in the right forum. 'managed' means this forum is for .NET C++ questions.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi
Could someone point out my code error here.
When I try to compile I get a C2065 OleDbConnection undeclared identifier
error
msg.
Here is my code:
#using <mscorlib.dll>
#using <system.data.dll>
using namespace System;
using namespace System::Data;
using namespace System::Data::OleDb;
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
// The connection
//string cnNwind;
OleDbConnection * conn = new OleDbConnection();
conn->ConnectionString = S "Provider=Microsoft.Jet.OLEBD.4.0; "
S"Data Source=C:\my_databases\taxLots.mdb";
// The connection string
try
{
// Open Database
conn->Open();
Console::WriteLine(S"Connected to database successfully!");
}
catch (OleDbException * pe)
{
Console::Write(S"Error occurred: ");
Console::WriteLine(pe->Message);
}
// Close Connection
if (conn->State != ConnectionState::Closed)
{
conn->Close();
}
Console::WriteLine(S"The database connection is now closed");
return 0;
}
Thanks for any insights.
--
BamaGrad
|
|
|
|
|
Hi;
I finally figured out my problem.
You have to have two references in order for your declared object to
recognized.
Add them to your references folder in the solutions explorer.
They are:
System
System.Data
|
|
|
|
|
Hi All,
I have a vector defined of type vector<char> theString in a function. I need to return this string to the main program, what should be the return type of the function?. I am using "char *" and I have a problem with it. Please let me know what should be the return type and how the function declaration should be. Any help greatly appreciated.
Thanks,
Turbo
char * readline(SOCKET *theSocket)
{
vector<char> theString;
char buffer;
bool bStringEnding = true;
while(bStringEnding)
{
if (recv(*(theSocket), &buffer, 1, 0) == -1)
{
return SERVER_SOCKET_ERROR;
WSACleanup();
}
if(buffer == '\n')
{
bStringEnding = false;
return theString;
}
else
theString.push_back(buffer);
}
return theString;
}
|
|
|
|
|
This is not managed C++, therefore you're asking in the wrong forum.
Why do you need vector<char> ? What's wrong with std::string ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
TurboNext wrote: if (recv(*(theSocket), &buffer, 1, 0) == -1)
Not very efficient way to perform socket communications.
led mike
|
|
|
|
|
Just try
1. vector<char> readline(SOCKET *theSocket); or
2. bool readline(SOCKET *theSocket, vector<char>* pVevChr);
Regards
|
|
|
|
|
Just try
1. vector < char > readline(SOCKET *theSocket); or
2. bool readline(SOCKET *theSocket, vector < char > * pVevChr);
Regards
|
|
|
|
|
We have been using the new override keyword in standard c++ projects.
I have a standard c++ library that includes something like this
class Base
{
virtual bool DoSomething() = 0;
};
class Derived
{
bool DoSomething() override;
};
This compiles fine
This header is included in my managed c++/cli project and because the override keyword has a slightly differnt meaning in CLI I get the following error when compiling the CLI project that includes this file
error C2217: 'override' requires 'virtual'
The simple solution is to change the derived class to be like this
class Derived
{
virtual bool DoSomething() override;
};
Obviously the preprocessor is doing all the includes before the compiler sees this so it has no way of knowing that the code come from a standard c++ project. Is there any other way to resolve this without changing the function declaration?
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
Try surrounding the code with the managed/unmanaged pragmas.
|
|
|
|
|
Josh,
The native code also needs override paired with virtual also! Here is an example taken out of Microsoft's documentation (How to: Declare Override Specifiers in Native Compilations ):
#include <stdio.h>
__interface I1 {
virtual void f();
};
class X : public I1 {
public:
virtual void f() override {}
virtual void g() override {}
};
|
|
|
|
|
George L. Jackson wrote: The native code also needs override paired with virtual also! Here is an example taken out of Microsofts documentation:
That is what I thought. The code in question was written by someone else and committed to source control yesterday. It does appear to compile and run without the virtual keyword. I think Ill have a word with him.
Interestingly the prama does not resolve the issue which would suggest that the /CLI option makes the compiler produce this error.
Thanks again for your help
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
Thanks again for all your help mate
We use the override keyword in our nonmanaged code to catch cases where people override a method thats not virtual
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
Hi,
I am trying to copy data from a structure
<br />
typedef struct OctetString {<br />
unsigned int length;<br />
unsigned char *value;<br />
} OctetString;<br />
I have only managed to copy the value using a for-loop and an ArrayList
<br />
OctetString* data;<br />
ArrayList^ bits = gcnew ArrayList();<br />
for(unsigned int i=0;i<data->length;i++)<br />
{<br />
bits->Add((char)*data->value);<br />
data->value++;<br />
}<br />
My question is: Is there a better way to copy the data into the ArrayList, and is
there a more suitable structure than a ArryList to handle binary data of different lengths?
/krissi
|
|
|
|
|
You could use an equivalent value class :-
value class MOctetString
{
unsigned int length;
array<unsigned char>^ value;
};
|
|
|
|
|
kristmun wrote: Is there a better way to copy the data into the ArrayList, and is
there a more suitable structure than a ArryList to handle binary data of different lengths?
They hide that information in the documentation[^]
led mike
|
|
|
|
|
Hi guys,
thanks for the advice.
It works now using the Copy method
<br />
array<unsigned char>^ value = {'a','b','c'};<br />
char* ptr = new char[value->Length];<br />
Marshal::Copy(value,0,(IntPtr)ptr,value->Length);<br />
and the other way around
<br />
int length = 3;<br />
char str[] = {'d','e','f'};<br />
char* pStr = &str[0];<br />
array<unsigned char>^ strArr = gcnew array<unsigned char>(length);<br />
Marshal::Copy((IntPtr)pStr,strArr,0,length);<br />
I didn't quite get the value class way 
|
|
|
|
|
Hi All,
My application doesnt compile if I use anything from namespace std. I have tried "using namespace std" and std::
Can anyone tell me what the problem could be?
Extremely sorry for asking a basic question. I am just a starter. Hope you all understand.
Thanks and Regards,
Anil
|
|
|
|
|
When you say it doesn't compile, what is the error ?
Did you #include what you're trying to use ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
Now the previous error disappeared. But I still get
error C2079: 'Logger::m_oStream' uses undefined class 'std::basic_ofstream<_Elem,_Traits>'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
Can you please help? I am using Visual Studio .Net 2003
Thanks and Regards,
Anil
|
|
|
|
|
If you could post a minimal code snippet that reproduces the error, it'd be easier to figure otu what headers you are missing.
|
|
|
|
|
Are you including iostream ( not iostream.h ) ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
right chris.....i am including iostream.....any problem with that...??
|
|
|
|