|
Dear All,
I have a VB6 Application which throws events. How can I capture these events in my another C#.Net Application?
Please help me providing articles or links.
Thanks in advance.
Mehedi Hasan
|
|
|
|
|
What kind of events does VB6 application throw? Can you give us the example?
|
|
|
|
|
Like Michael said, how is the VB6 event being thrown. Without knowing, we can't really help.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
seem like this guy " M A A Mehedi Hasan" just want to post something in our forum.. I don't know why there are so many people like that.. they just post the question and if we ask them back, they never reply..
|
|
|
|
|
Michael Sync wrote: don't know why there are so many people like that.. they just post the question and if we ask them back, they never reply..
I figure I either made them feel really stupid or answered their inquiry.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi guys i had solution which im confusing that how a body of mail takes streamreader's colllection from a text file. How can i do this? can anyone give me a suggestion, would be great!
function readtext reads a myfile.txt and i want invoke this method to mail.Body. by send mail event.
private static void readtext()
{
FileStream fs = new FileStream("C:\\myfile.txt", FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
sw.BaseStream.Seek(0, SeekOrigin.Begin);
string str = sw.ReadLine();
while (str != null)
{
str = sr.ReadLine();
}
sr.Close();
fs.Close();
}
}
thanks!
so much of happy ending...
|
|
|
|
|
Rephrase it, you aren't making much sense.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Look into System.Net.Mail (specifically the MailMessage and SmtpClient classes) to send the emails. Also, your method should return the string it is building. Perhaps you should do something like the following (be careful if the file can be large, as it may throw a memory overflow exception)...
private static string ReadText(string fullFilePath) {
FileStream fs = null;
StreamReader sr = null;
try {
fs = new FileStream(fullFilePath, FileMode.Open, FileAccess.Read);
sr = new StreamReader(fs);
return sr.ReadToEnd();
} finally {
if (sr != null)
sr.Close();
if (fs != null)
fs.Close();
}
} Alternatively, you could send the file as an attachment. Examples of this can be found when you examine the MailMessage class. Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
thanks, its really helpful!! jeff.
so much of happy ending...
|
|
|
|
|
Hi,
I'm having trouble in transferring arrays of short integers from C++ library to C# application.
I got the sources of a library, written in C++, that defines interface in IDL file.
The original methods transfer "basic" objects, such as BOOL and BSTR.
I need to add a new method to the interface for transferring two arrays of short integers.
For that purpose, I create two safe arrays and populate them with the numbers.
However, when I try to invoke the C# method I get TypeMismatch error code (when I pass only the string objects, it works OK).
The C++ code includes the following definition in IDL file:
library CodecLib
{
...
dispinterface _ILiveEvents
{
properties:
methods:
...
[id(4), helpstring("method DataReady")] HRESULT DataReady([in] BSTR strForward, [in] SAFEARRAY(short) FwdBuffer,
[in] BSTR strReturn, [in] SAFEARRAY(short) RetBuffer);
};
...
};
The following C# code implements the interface defined in the IDL file:
private void DataReady(string sForward, Array ForwardData,
string sRetrun, Array ReturnData)
{
...
}
The following C++ code prepares the data in the safe arrays:
void CLive::DataReady(short *pFwdBuf, short *pRetBuf, int nBufferSize)
{
long lIndex;
SAFEARRAYBOUND ArrayBound[2];
ArrayBound[0].cElements = nBufferSize;
ArrayBound[0].lLbound = 0;
ArrayBound[1].cElements = nBufferSize;
ArrayBound[1].lLbound = 0;
m_pFwdBuffer = SafeArrayCreate(VT_I2, 1, &ArrayBound[0]);
m_pRetBuffer = SafeArrayCreate(VT_I2, 1, &ArrayBound[1]);
// Set data in safe arrays
for (lIndex=0; lIndex<nBufferSize; lIndex++)
{
SafeArrayPutElement(m_pFwdBuffer, &lIndex, &pFwdBuf[lIndex]);
SafeArrayPutElement(m_pRetBuffer, &lIndex, &pRetBuf[lIndex]);
}
// Send data to clients
Fire_DataReady(m_strForward, m_pFwdBuffer, m_strReturn, m_pRetBuffer);
// Release safe arrays
SafeArrayDestroy(m_pFwdBuffer);
SafeArrayDestroy(m_pRetBuffer);
m_pFwdBuffer = NULL;
m_pRetBuffer = NULL;
}
The following C++ code distributes the data to the clients.
However, calling Invoke() returns TypeMismatch error, with uArgErr equals to 3:
HRESULT Fire_DataReady(BSTR strForward, SAFEARRAY *pFwdBuf,
BSTR strReturn, SAFEARRAY *pRetBuf)
{
HRESULT hr = S_OK;
T * pThis = static_cast<T *>(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);
if (pConnection)
{
CComVariant avarParams[4];
avarParams[0] = strForward;
avarParams[0].vt = VT_BSTR;
avarParams[1] = pFwdBuf;
avarParams[1].vt = VT_ARRAY;
avarParams[2] = strReturn;
avarParams[2].vt = VT_BSTR;
avarParams[3] = pRetBuf;
avarParams[3].vt = VT_ARRAY;
CComVariant varResult;
unsigned int uArgErr;
DISPPARAMS params = { avarParams, NULL, 4, 0 };
hr = pConnection->Invoke(4, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, &uArgErr);
}
}
return hr;
}
|
|
|
|
|
|
hello everyone,
how I can insert image to database sqlserver by c# code.
and what the type of image that can save in database sqlserver.
|
|
|
|
|
|
Good day everyone,
I have a problem that I really need someone help.
I have an array of objects that is filled from the content of a text file. One line in ther text file contains name,address and employeeID.
The problem is that I can not compare the employeeID in the object with a given employeeID.
How can I get the value of employeeID out of the the array of objects?
Please help.Thanks much in advance
Employee[] employeeList = new Employee[100];
employeeList = new Employee[100];
EmpFileReader empfile = new EmpFileReader();
employeeList = empfile.readFile();
//getEmployeeID returns ID
if(employeeList[i].getEmployeeID()== employeeID )
System.out.println(employeeList[i]);
eric
|
|
|
|
|
First thing you need to do is that you have to ensure whether readFile() method can parse the value from text file to the employee object.
Once you are sure about readFile(), you can just loop through the array and compare the ID..
eric_tran wrote: Employee[] employeeList = new Employee[100];
employeeList = new Employee[100];
No need to instantiate the array twice. btw.
|
|
|
|
|
Hi Michael,
I'm sure that the array of object has all data pulled from the text file.
I can get the value of employeeID from the array of object, but when I compare with a given string, then it does not work.
for (int i=0; i<noemployees; i++)<br="" mode="hold"> {
if(employeeList[i].getEmployeeID()== "1234" )
System.out.println(employeeList[i]);
}
eric
modified on Sunday, December 30, 2007 6:25:21 AM
|
|
|
|
|
Try to write all id of employees array.. see whether you got all employee ids (including the one that you want to search) or not..
For each(Employee emp in Employees){<br />
Console.WriteLine(emp.ID.ToString());<br />
}<br />
<br />
|
|
|
|
|
hi,
i did a Dll which i use on HTML page.
namespace Control {
public interface myIn
{
}
public partial class UserControl1 : UserControl, myIn
{
public UserControl1() {
InitializeComponent();
}
}
i want to write to a file on the client's computer:
private void button2_Click(object sender, EventArgs e)
{
StreamWriter f = new StreamWriter(@"c:\\myfile.txt", false);
f.WriteLine("test");
f.Flush();
f.Close();
}
when i click this button i get an error message in the browser indicating that an unpremessioned taks took place - and the file is not written.
does anybody know how to write to the clients computer (via this COM object)?
thanks,
Samy
|
|
|
|
|
samy100 wrote: i want to write to a file on the client's computer
It's not allowed to do that for security reason unless the client has added your site in trusted website..
|
|
|
|
|
Hello,
I think your code will going to write the file on the Server. but It is not permitted. Actually this is Server side code. You may test this on other computer(cliant) on LAN, I think it will write on the server where it is reside.
This is the Suggestion. Please reply after test or found solution.
Best of Luck.
Dipak
|
|
|
|
|
it is in Javascript - so it is in the client's computer not the Server side.
|
|
|
|
|
I have a class like this:
class StateManager
{
bool IsLoading { get { ... } }
bool IsValidated { get {... } }
}
- and I want to bind to one of these getters, i.e. pass to some function which of these properties to ask (some time later), like this:
void DoSomething()
{
CheckLater( bind(StateManager.IsLoading));
}
void CheckIt(something property)
{
bool state = unbindAndCallGetter(property);
if (!state)
;
}
Ideally, I don't have to add to StateManager anything (per-property) except the property itself.
bind can get the name of the property as a string, or anything that's simple to type.
unbindAndCallGetter can use reflection (performance-wise it's ok in this situation)
Currently, I am passing a delegate { return StateManager.IsLoading; } , which is flexible but could be shorter, and is not good for diagnostics (knowing in CheckIt that it was "IsLoading" what failed would be immensely useful).
Any other suggesiton welcome - my goal is to simplify syntax and readability.
|
|
|
|
|
I am working on a program in C# the program is like a personal database holds numbers, names, little bit of everything even have a section for calculating and managing my bills. I have pretty much everything done, majority of the code and have the MySql DB finished. The problem I have is I want the information I have in the DB to be pulled and placed in txt boxes. I can pull the info and put it in a DataGrid but that is not what I am wanting to do. I am just having a hard time trying to figure out how to get the DB information to be pulled into the text boxes that I have. I did have this similar program using XML, but I want to take it a step further.
|
|
|
|
|
ok i think i have it now, just need to make some minor alterations, and instead of using a load button i will be using a the Select.Item.Index from a listbox to retrieve the information from the database. if anyone has any comments or notices room for correction please let me know. i enjoy C# but i am new to the combination of C# & MySql.
private void loadBtn_Click(object sender, EventArgs e)<br />
{<br />
string strFindMovie = "SELECT movie_name FROM movie WHERE movie_id='1'";<br />
<br />
MySql.Data.MySqlClient.MySqlConnection conDatabase = new <br />
MySql.Data.MySqlClient.MySqlConnection("Data Source=localhost; Database=moviesite; username=******; password=*****");<br />
MySql.Data.MySqlClient.MySqlCommand cmdDatabase = new <br />
MySql.Data.MySqlClient.MySqlCommand(strFindMovie, conDatabase);<br />
<br />
conDatabase.Open();<br />
<br />
MySql.Data.MySqlClient.MySqlDataReader rdrMovie;<br />
rdrMovie = cmdDatabase.ExecuteReader();<br />
<br />
while (rdrMovie.Read())<br />
{<br />
this.nameTB.Text = rdrMovie.GetString(0);<br />
}<br />
<br />
rdrMovie.Close();<br />
conDatabase.Close();<br />
}
modified on Saturday, December 29, 2007 5:46:14 PM
|
|
|
|
|
shadowhazard wrote:
ok i think i have it now, just need to make some minor alterations, and instead of using a load button i will be using a the Select.Item.Index from a listbox to retrieve the information from the database. if anyone has any comments or notices room for correction please let me know. i enjoy C# but i am new to the combination of C# & MySql.
That sounds like the right thing to do. It's good to see that you solved the problem yourself. Way to go
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|