|
I have a fairly large application that I want to add a web interface to. The application is designed as a two layer application. The user interface and the so called API, which does all the work.
I would like to be able to call the API which is written in pure C with no operating system dependencies except for telecommunications.
I have tried to add a reference in VS.NET to the API's .DLL but it doesn't allow me to.
Is there an easy way to do this with out converting the entire application to C#? For fun, I tried to compile it using VS.NET 1.1 as a C++ application and the 1st program out of about 200 gave me 100+ errors.
Converting it to compile under VS.NET C++ I thought would be easy, but would take too long. Anyone have any ideas??
Oh BTW, my compiler that I'm currently using for my C development is Watcom 10.6B. I know its old and unsupported but I understand it. I'm trying to learn VS.NET...
Thanks,
Glenn
|
|
|
|
|
You could try using P/Invoke, which would involve some [DllImport] usage. P/Invoke[^]
|
|
|
|
|
So, ehr...
..hope you won't think that this question is in the wrong forum, but..
You remember all the good'ol'SQL APIs like SQLConnect, SQLFetch, ... ?
How can I access those from a C# app?
I've tried to use the System.Data.SqlClient namespace stuff,
but that is targetted for SQL Server DBs,
and I am just trying to do something more ODBC-oriented (i.e. that would
work with other DBMS as well).
To be specific: I really, really, **really** need to
execute an SQL<foo> call (rather than using Data Sets, and such).
Is it possible in C#, or should I just go back to C++ ?
Suggestions anyone?
Thanks in advance,
F.O.R.
|
|
|
|
|
1. System.Data.OleDbClient
2. SqlConnection,SqlCommand and OleDbConnection,OleDbCommand can execute SQL statements. You can use an OleDbDataReader (SQlDataReader if MSSQL) to retun records in a fast forwar-only cursor and do as you wish with the data. xxxCommand and xxxConnection can also execute quries that have no return data or onlay a single scalar value.
Genius may have its limitations, but stupidity is not thus handicapped. - Elbert Hubbard
|
|
|
|
|
Thanks Rob,
but that's not exactly what I was looking for.
I suspect I'll end up moving to C++ one way or the other
Thanks again,
F.O.R.
|
|
|
|
|
Look at the System.Data.Odbc (only in 1.1) and System.Data.OleDb namespaces for setting up connections and executing commands etc.
The OdbcCommand and OleDbCommand objects both have the ExecuteNonQuery method (and more) to execute SQL statements without involving DataSet and DataTable objects...
|
|
|
|
|
Hmmm...
..I didn't know that 1.1 had an Odbc namespace!
I'll take a look, thanks
F.O.R.
|
|
|
|
|
While the previous answers were complete and technically correct, why do I still have the feeling you are using the wrong tool for the job?
You can do it on anything you choose - from .bat to .net - A customer
|
|
|
|
|
Because indeed I am.
I am looking for something that has a 1:1 correspondence to the sql.h library from C/C++.
Now, while C# has alternatiuve ways to achieve the same goals (all of the Data namespace, for instance), I am not surprized to find that C# keeps you away from such low level kind of stuff.
It indeed makes much more sense for me to use a C++ (managed or not) app in this case,
but I figured I could look around for a bit before giving up on being more modern
F.O.R.
|
|
|
|
|
OK, before I give up on this, let me rephrapse the question
Any way I can stick in a C# App the following lines?
<br />
sqlr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &h_env);<br />
sqlr = SQLSetEnvAttr(h_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_UINTEGER);<br />
and other statements like that ?
They are taken from a C/C++ app that includes <sql.h> and <sqlext.h>.
Maybe I can place them in an un-managed section?
It would solve soooo many problems !
Thanks in advance for any input,
F.O.R.
|
|
|
|
|
This is just a shot in the dark but you could take a look at addng a COM reference to the Microsoft SQLDMO Object Library. You might find what you need in there.
|
|
|
|
|
if anyone have a good idea about how to creat an html to image component
i tried :
A.
capture a web browser controll
prob
1. a win form app , we need to put the web controll inside A dll file. and that a little messy ...
2.when u capture it will only get what u c ...
and not the whole page.
B.
generating a url file on the server
then open this file with the windows shell getting the
image that gnerated by the server
prob. wont work on windows 2003 server.
Any help or idea would be most welcome !
|
|
|
|
|
try to start search from here:
Thumbnail Generator Web Service
Description: The Thumbnail Generator Web Service creates a .gif image of a specified URL.
<br />
http:
<br />
http:
Found from here:
<br />
http:
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
thnx for the reply,
i alrady tried the web service , its very nice but wont work on the 2003 servers, or xp machine u get an exception when u try to extract the image with the iextractimage interface ,
the same code work with win 2000 wont work with 2003 ...
|
|
|
|
|
Never saw this on work Sorry - once I've searched the net for this info and this what I found. Never used it and didn't know if this work.
P.S. This is strange that some interfaces (!!!) doesn't work somewhere May be it's depends on browser version ??
"I have not failed.
I've just found 10,000 ways that won't work."
- Thomas Alva Edison (1847-1931)
|
|
|
|
|
I have seen several helpful examples of how to call API functions but I am confused about translating the data types. For example, I have seen DWORD parameters translated to both int and uint in c#. I am using a function that has a char[] parameter which I think should be translated as sbyte, but I'm just not sure. Any direction on a good reference for this?
Tym!
|
|
|
|
|
Try this: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cscon/html/vclrfcomparisonbetweenccsharp.asp
Glenn
|
|
|
|
|
|
I have a richtext control, is there a way to count number of words or do I make my own function?
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
This will work assuming only one space is between each word:
this.richTextBox1.Text.Trim().Split(" ".ToCharArray()).Length;
|
|
|
|
|
Is there any way of obtaining the height of a main menu (menubar) or is it always the same size regardless of the screen resolution (i think its 20 pixels).
The reason why i need to know the height is that i'm trying to make a form with a picturebox inside a panel and resize the form so that it can view the whole image (assuming that my screen res is larger than the image). So i need to do some calculations and stuff..
|
|
|
|
|
Assuming you aren't using owner drawn menus the menu height is given by System.Windows.Forms.SystemInformation.MenuHeight .
James
"then when you go to bed...wait, you dont do that do you....ok....when you plug into the 'hive mind' to charge yourself, ill hack into your head"
Nnamdi Onyeyiri over MSN
|
|
|
|
|
Thanks. That did the trick.
|
|
|
|
|
I'm trying to call the Win32 SDK function CreateCompatibleDC in my application, I declared the function like this:
[DllImport("gdi32.dll")]
protected static extern IntPtr CreateCompatibleDC(IntPtr hDC);
but whenever i call it (with the hDC as IntPtr.Zero) it fails. When I check the error using the GetLastError function it is error 8, not enough memory. Why would this happen, I have plenty of RAM? Is there something i'm doing wrong?
Any help would be greatly appriciated,
thanks in advance,
dave
Dave Kerr
focus_business@hotmail.com
http://www.codechamber.com
|
|
|
|
|
Try the following:
[DllImport("user32.dll")]
public static extern IntPtr GetDC(IntPtr hWnd);
public static extern IntPtr CreateCompatibleDC(IntPtr HDC);
[DllImport("gdi32.dll")]
IntPtr ScreenDC = GetDC(IntPtr.Zero);
IntPtr NewDC = CreateCompatibleDC(ScreenDC);
HTH
-Nick Parker
|
|
|
|