|
Hi everybody
I have old dll(s) that implemented with Visual Basic 6.0 and Borland Delphi 6.0 and Visual C++ 6.0
I haven't the source of these dlls, So I want to know how can import these dll to C# .Net as a reference.
Best Regards,
Reza Shojaee
|
|
|
|
|
If it's a COM component you can just add it from the COM tab and let VS create the Interop.
|
|
|
|
|
I tried with COM tab but VS doesn't accept it
Best Regards,
Reza Shojaee
|
|
|
|
|
Do you receive some sort or Error ?
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Then it's not a COM-based .DLL. You'll have to use P/Invoke to get at the functions it exposes. I hope you have all the documentation on the functions because, if you don't, you're going to find it nearly impossible to call the functions in the .DLL.
|
|
|
|
|
You need to look up interop services. You can use tlbimp.exe to generate your interop if it is COM (which from the post above seems not to be the case). Otherwise, you can use the DLLImport attribute and reference the functions this way. You will find it tricky to figure out the proper types to use in the function signature, so you need to research a little. But, this is your start.
[DllImport("TheCplusplus.dll")]
static extern uint BTSeparateItems([In, MarshalAs(UnmanagedType.BStr)] string filePath, out object obj);
|
|
|
|
|
Hi, im new to using stored procedures and i have the following stored procedure...
CREATE OR REPLACE PROCEDURE DRL_PROCEDURE2(var_SOURCE_OBJECTID IN varchar2, var_NEW_OBJECTID OUT varchar2)
AS
BEGIN
SELECT MAX(NEW_OBJECTID)
INTO var_NEW_OBJECTID
FROM DRL_CONVERSION
WHERE SOURCE_OBJECTID = var_SOURCE_OBJECTID;
END;
I want to be able to call this procedure from my windows form application and display the result of the stored procedure into a label or a datagrid using C#...could someone please help me! Thanks in advance!
|
|
|
|
|
Just google ADO.NET, there are thousands of examples
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
|
That's not a procedure; it's just a simple query. I'd pass it to ExecuteScalar, that's what it's for.
As the other person said; read up on ADO.NET.
|
|
|
|
|
Here's a helper class I use. It's lightweight but contains a few useful methods. Create a new class in your project and call it 'DbAssist' and copy this code in there. I haven't documented the methods so if you have trouble understanding anything just reply and I will assist. Cheers
using System;
using System.Configuration;
using System.Data;
namespace Common.Data {
public static class DbAssist {
private static void CheckConnectionClosed(IDbConnection connection) {
if (connection.State != ConnectionState.Closed) {
throw new InvalidOperationException("An error has occurred: connection is not in closed state.");
}
}
public static string GetConnectionString(string key) {
try {
return ConfigurationManager.ConnectionStrings[key].ConnectionString;
} catch (NullReferenceException ex) {
throw new ConfigurationErrorsException("An error has occurred: "
+ key + " does not exist in config.", ex);
}
}
public static object ExecScalar(string sqlText, IDbConnection connection) {
return ExecScalar(sqlText, connection, CommandType.Text);
}
public static object ExecScalar(string sqlText, IDbConnection connection, CommandType cmdType) {
return ExecScalar(sqlText, connection, cmdType, null);
}
public static object ExecScalar(string sqlText, IDbConnection connection,
CommandType cmdType, IDataParameter[] parameters) {
CheckConnectionClosed(connection);
using (connection) {
connection.Open();
IDbCommand command = connection.CreateCommand();
command.CommandText = sqlText;
command.CommandType = CommandType.StoredProcedure;
if (parameters != null) {
foreach (IDataParameter p in parameters) {
command.Parameters.Add(p);
}
}
return command.ExecuteScalar();
}
}
public static IDataReader ExecReader(string sqlText, IDbConnection connection) {
return ExecReader(sqlText, connection, CommandBehavior.CloseConnection);
}
public static IDataReader ExecReader(string sqlText, IDbConnection connection,
CommandBehavior behavior) {
return ExecReader(sqlText, connection, CommandType.Text, behavior);
}
public static IDataReader ExecReader(string sqlText, IDbConnection connection,
CommandType cmdType, CommandBehavior behavior) {
CheckConnectionClosed(connection);
connection.Open();
IDbCommand command = connection.CreateCommand();
command.CommandText = sqlText;
command.CommandType = cmdType;
return command.ExecuteReader(behavior);
}
public static IDataReader ExecReader(string sqlText, IDbConnection connection,
CommandType cmdType, IDataParameter[] parameters, CommandBehavior behavior) {
CheckConnectionClosed(connection);
IDbCommand command = connection.CreateCommand();
command.CommandText = sqlText;
command.CommandType = cmdType;
if (parameters != null) {
foreach (IDataParameter p in parameters) {
command.Parameters.Add(p);
}
}
return command.ExecuteReader(behavior);
}
public static T GetDataFromReader<T>(IDataReader reader, string fieldName, T fallbackValue) {
int ordinal = reader.GetOrdinal(fieldName);
if (!reader.IsDBNull(ordinal)) {
return (T)reader.GetValue(ordinal);
}
return fallbackValue;
}
}
}
|
|
|
|
|
Hi,
I want to Write DWORD Value in HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer.
My application writes the value registry only if i run my application as an administrator on vista.
I want on normal exe execution.
and I dont want to disable UAC on vista.
Reply ASAP.
Regars,
Sunil G.
|
|
|
|
|
You can atempt to change permision, althou i think UAC will prevent. Other option is to modify your manifest, so that your app runs in admin mode. But everytime you open application, it will pop up UAC confirmation window.
|
|
|
|
|
Hi,
I Dont want UAC confirmation window.
Regards,
Sunil G.
|
|
|
|
|
At install time for your application (because you will be running your app as admin at installation) set the ACL for that specific Registry Entry and allow users to write to it.
This will ge you started:
this [^]
|
|
|
|
|
Hello, I am using date time picker to display month and a year. How can i make calendar not to show days, only Month and a year?
|
|
|
|
|
Set the DateTimePicker's properties :
Format: Custom
CustomFormat: MM.yyyy
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
You have missunderstood me, It does display as i want, but when i bring up calendar, there I can see days, but i do not wan't it to be seen
|
|
|
|
|
Well, in Load event write code to format your DateTimePicker.
dateTimePicker1.CustomFormat = "MM.yyyy";
dateTimePicker1.Format = DateTimePickerFormat.Custom;
I hope I have understood you now!
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
|
Hi,
Will be solution for you if you set property ShowUpDown=true of dateTimePicker ?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Not exactly what i had in mind, but it is still better. Maybe i woud need to look for custom control
|
|
|
|
|
Why not create your own user control with 2 comboboxes on it? The first combobox will have the months, the 2nd will have the year values.
|
|
|
|
|
The only thing i have ask is if I can modify calendar that pops up after clicking on the DateTimePicker. I Wanted that callendar to display Month instead days. If you click the month, callendar would "zoom out". I wanted that view for that callendar
|
|
|
|
|
Hi,
Is the following grid layout possible with DataGridView in VB.net? Kind of similiar to html table layout. I'm adding data cell in one row. However I'm not sure on how to get the split row in data grid row.
|
|
|
|