=?iso-8859-1?Q?Andr=E9_Malafaya_Baptista?=
10/23/2002 3:36:00 AM
The System.Runtime.InteropServices.Marshal class has lots=20
of conversion functions between managed and unmanaged=20
types. In your particular case, I believe you wish to=20
convert a String to an ANSI unmanaged string (aka char*)=20
which you can use later as a byte*.
In order to do this, you must mark this portion of code=20
as unsafe, pin your String and then call PtrToStringAnsi
(...) static method of the Marshall class.
I don't recall the method's syntax exactly, but first you=20
need to extract the pointer to your String (ToPointer()?)=20
and use it as a parameter for the PtrToStringAnsi method.
HTH
Andr=E9
>-----Original Message-----
>I am trying to use C# to open a an ODBC connection,
>(my database vendor is Centura SQL Base.)
>The ODBC call is straight forward when called from=20
managed=20
>C++, namely it is like this:
>
>SQLHDBC hdbc =3D SQL_NULL_HDBC; =09
>// connect
>retcode =3D SQLConnect( hdbc, (SQLCHAR*)"odbcname",=20
SQL_NTS,=20
>(SQLCHAR*)"sysadm", SQL_NTS, (SQLCHAR*)"sysadm",=20
SQL_NTS);
>if (retcode =3D=3D SQL_SUCCESS || retcode =3D=3D=20
>SQL_SUCCESS_WITH_INFO) { . . . etc...
>
>I C# I am stuck because I do not know what is the=20
datatype
>(SQLCHAR*) in C#. Since I Added the reference to this=20
API,
>I am getting intelli-sense help and it is telling me=20
that=20
>the expected type is byte * (pointer to byte). I tried=20
>everything I know to convert a string such as "sysadm"=20
>into a pointer to byte, and I always get a compile error.
>If anyone knows how to convert a string to a byte=20
pointer -
> it will be greatly appreciated.
>
>=20
>.
>