Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 04 Mar 2005 @ 19:32:18 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


Subj:   Re: CLI with Microsoft .NET
 
From:   Matthew Winter

Hi,

I have not tried out this, but I would expect the C# call to be something like

     [DllImport("DBCPrims.dll", CharSet=CharSet.Auto)]
     public static extern int DBCQuery(int sessID, IntPtr reqID, StringBuilder sql
            , IntPtr usingData, int usingLength, IntPtr buff, IntPtr buffLen);

.NET handles ASCII character arrays fine, and using the StringBuilder class we do not have to do any conversion as effectively under the covers of .NET, it really is just a CHAR * being manipulated in the usual manner.

I have used the IntPtr for reqID and buffLen just to be sure, as I know these are far pointer safe. The other alternative would be to use a referance to an int valuetype as follows:

     [DllImport("DBCPrims.dll", CharSet=CharSet.Auto)]
     public static extern int DBCQuery(int sessID, ref int reqID, StringBuilder sql
            , IntPtr usingData, int usingLength, IntPtr buff, ref int buffLen);

The second would be more straight forward to code with, however would need to be tested, to be sure the "ref int" is far pointer safe. Could not find any docs to say they are not, but a quick test would be prudant.

Hope this helps.


Regards

Matthew Winter



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023