convert to C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pcPirate

    convert to C#

    Hi,

    Can anyone help me to convert the following VB6 code into C#???

    Declare Function SQLSetConnectOp tion Lib "ODBC32.DLL " (ByVal hDbc As Long,
    ByVal iOption As Integer, ByVal lValue As Long) As Integer

    Thanks in advance
    pcPirate


  • Kevin Chandler

    #2
    Re: convert to C#

    Here is some code that I used to import some Win32 functions from a Kernel32.Dll. I would suspect you could use the same code (obviously modified) to solve your problem:

    internal class Kernel32
    {
    [DllImport("kern el32.dll", SetLastError=tr ue )]
    public static extern int GetPrivateProfi leString( string szApplicationNa me,
    string szKeyName, string szDefault, StringBuilder szReturnValue, int nSize, string szFilename );
    [DllImport("kern el32.dll", SetLastError=tr ue )]
    public static extern int GetPrivateProfi leSectionNames( byte[] lpszReturnBuffe r,
    int nSize, string szFilename );
    }

    Maybe something like:
    internal class ODBC32
    {
    [DllImport("kern el32.dll", SetLastError=tr ue )]
    public static extern short SQLSetConnectOp tion ( int hDbc, short iOption, int lValue);
    }

    Don't forget that the data types are differenent between c/c++ and c#. C#int = c++long

    Good Luck,
    Kevin

    "pcPirate" <phoon_@hotmail .com> wrote in message news:OcAF0qYgDH A.3204@TK2MSFTN GP11.phx.gbl...[color=blue]
    > Hi,
    >
    > Can anyone help me to convert the following VB6 code into C#???
    >
    > Declare Function SQLSetConnectOp tion Lib "ODBC32.DLL " (ByVal hDbc As Long,
    > ByVal iOption As Integer, ByVal lValue As Long) As Integer
    >
    > Thanks in advance
    > pcPirate
    >
    >[/color]

    Comment

    • Frecklefoot

      #3
      Re: convert to C#

      > Declare Function SQLSetConnectOp tion Lib "ODBC32.DLL " (ByVal hDbc As Long,[color=blue]
      > ByVal iOption As Integer, ByVal lValue As Long) As Integer[/color]

      Ug. I am not up on VB6, but I'll give it a shot:

      public int SQLSetConnectOp tion( long hDbc, int iOption, long lValue )
      {
      ...
      return someInt;
      }

      I don't know what that "ODBC32.DLL " is for, but maybe you can work it in
      there somehow. Also, I assumed the function was public, but you can change
      it to protected or private if need be. Lastly, it looks like a forward
      declaration of a function (a function prototype), but those aren't used in
      C#, so you'll have to include the function's code with the function
      declaration.

      Good luck! :^)


      Comment

      • Arvid Blandhol

        #4
        Re: convert to C#

        using System.Runtime. InteropServices ;
        [DllImport("ODBC 32.DLL")]
        static extern int SQLSetConnectOp tion(UInt32 hDbc, int iOption, UInt32
        lValue);

        See the following MSDN Magazine article for more info:
        Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

        ....
        Arvid

        "pcPirate" <phoon_@hotmail .com> wrote in message
        news:OcAF0qYgDH A.3204@TK2MSFTN GP11.phx.gbl...[color=blue]
        > Hi,
        >
        > Can anyone help me to convert the following VB6 code into C#???
        >
        > Declare Function SQLSetConnectOp tion Lib "ODBC32.DLL " (ByVal hDbc As Long,
        > ByVal iOption As Integer, ByVal lValue As Long) As Integer
        >
        > Thanks in advance
        > pcPirate
        >
        >[/color]


        Comment

        • pcPirate

          #5
          Re: convert to C#

          Okay, thanks guy

          another favour pls...
          how do you change this from VB6 into c#

          Dim rdoEnv As RDO.rdoEnvironm ent
          Dim rdoEnvs As RDO.rdoEnvironm ents

          ' Set the RDO environment
          Set rdoEnvs = rdoEngine.rdoEn vironments
          Set rdoEnv = rdoEnvs(0)

          (Ya, this is rdo, hee hee... pls help....)

          Thanks in advance.
          pcPirate

          "Arvid Blandhol" <a@n.com> wrote in message
          news:%23g1w$5dg DHA.2248@TK2MSF TNGP09.phx.gbl. ..[color=blue]
          > using System.Runtime. InteropServices ;
          > [DllImport("ODBC 32.DLL")]
          > static extern int SQLSetConnectOp tion(UInt32 hDbc, int iOption, UInt32
          > lValue);
          >
          > See the following MSDN Magazine article for more info:
          > http://msdn.microsoft.com/msdnmag/issues/03/07/NET/
          > ...
          > Arvid
          >
          > "pcPirate" <phoon_@hotmail .com> wrote in message
          > news:OcAF0qYgDH A.3204@TK2MSFTN GP11.phx.gbl...[color=green]
          > > Hi,
          > >
          > > Can anyone help me to convert the following VB6 code into C#???
          > >
          > > Declare Function SQLSetConnectOp tion Lib "ODBC32.DLL " (ByVal hDbc As[/color][/color]
          Long,[color=blue][color=green]
          > > ByVal iOption As Integer, ByVal lValue As Long) As Integer
          > >
          > > Thanks in advance
          > > pcPirate
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...