473,414 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

convert to C#

Hi,

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

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

Thanks in advance
pcPirate
Nov 15 '05 #1
4 3112
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("kernel32.dll", SetLastError=true )]
public static extern int GetPrivateProfileString( string szApplicationName,
string szKeyName, string szDefault, StringBuilder szReturnValue, int nSize, string szFilename );
[DllImport("kernel32.dll", SetLastError=true )]
public static extern int GetPrivateProfileSectionNames( byte[] lpszReturnBuffer,
int nSize, string szFilename );
}

Maybe something like:
internal class ODBC32
{
[DllImport("kernel32.dll", SetLastError=true )]
public static extern short SQLSetConnectOption ( 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" <ph****@hotmail.com> wrote in message news:Oc**************@TK2MSFTNGP11.phx.gbl...
Hi,

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

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

Thanks in advance
pcPirate

Nov 15 '05 #2
> Declare Function SQLSetConnectOption Lib "ODBC32.DLL" (ByVal hDbc As Long,
ByVal iOption As Integer, ByVal lValue As Long) As Integer


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

public int SQLSetConnectOption( 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! :^)
Nov 15 '05 #3
using System.Runtime.InteropServices;
[DllImport("ODBC32.DLL")]
static extern int SQLSetConnectOption(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" <ph****@hotmail.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
Hi,

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

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

Thanks in advance
pcPirate

Nov 15 '05 #4
Okay, thanks guy

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

Dim rdoEnv As RDO.rdoEnvironment
Dim rdoEnvs As RDO.rdoEnvironments

' Set the RDO environment
Set rdoEnvs = rdoEngine.rdoEnvironments
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:%2****************@TK2MSFTNGP09.phx.gbl...
using System.Runtime.InteropServices;
[DllImport("ODBC32.DLL")]
static extern int SQLSetConnectOption(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" <ph****@hotmail.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
Hi,

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

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

Thanks in advance
pcPirate


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
6
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. ...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.