|
|
First you should change
A.Asif wrote: public void SearchFiles(ArrayList list)
{
DataEvent(list); //raising event for testing
}
to
<br />
public void SearchFiles(ArrayList list)<br />
{<br />
if (DataEvent != null)<br />
DataEvent(list);
} <br />
just to handle the case when no handler is attached to the event.
Then if you've got an RaiseEventClass object (call it "myObj") and want to handle the event just use
myObj.DataEvent += new RaiseEventDelegate(myHandler )
where myHandler is a function like
<br />
void myHandler(ArrayList files)<br />
{<br />
}<br />
By the way: afert typing "+= new" in the line where you attach the event you can hit <tab> twice and VS will write a handler-function for you (so you don't have to check the delegate to know exactly what kind of parameter / return you have to use)
One other comment:
you should include a "sender" parameter in every event you write (like object sender, or RaseEventClass sender - this helps you handle events from many sources in the same handler function and is always a good pattern.
|
|
|
|
|
I create a dll in runtime the code is following
<br />
Microsoft.CSharp.CSharpCodeProvider pr = new Microsoft.CSharp.CSharpCodeProvider();<br />
CompilerParameters cp = new CompilerParameters();<br />
string pathtoicon = @"f:\nido\em.ico";<br />
<br />
cp.CompilerOptions = "/target:library" + " " + "/win32icon:" + "\"" + pathtoicon + "\"";<br />
cp.GenerateExecutable = true;<br />
cp.IncludeDebugInformation = false;<br />
cp.EmbeddedResources.Add(@"E:\7.jpg");<br />
cp.OutputAssembly = "dgt.dll";<br />
cp.GenerateInMemory = false;<br />
cp.ReferencedAssemblies.Add("System.dll");<br />
cp.ReferencedAssemblies.Add("System.Data.dll");<br />
cp.ReferencedAssemblies.Add("System.Deployment.dll");<br />
cp.ReferencedAssemblies.Add("System.Drawing.dll");<br />
cp.ReferencedAssemblies.Add("System.Windows.Forms.dll");<br />
cp.ReferencedAssemblies.Add("System.Xml.dll");<br />
cp.TreatWarningsAsErrors = false;<br />
CompilerResults cr = pr.CompileAssemblyFromFile(cp);<br />
But cannot get the 7.jpg image back from the dll
I know there is no namespace and class but how can i get it back
Help me out plz
|
|
|
|
|
|
Hii
Could anyone please tell me that how to set the password of MYSql Database in runtime with C#.
Actually what currently i have done is i have installed MYSql and configured it and set the password there and i have hard coded the password in the connection string.
Is there any way to choose and set the password of MySql Database at runtime through C# code.
Any help will be appreciated.
Thanking You
Imran
|
|
|
|
|
set password = password("newone"); is the query for changing password. Try passing this through ExecuteNonQuery() .
|
|
|
|
|
|
ImranTech,
Just use AppConfig.
Regards,
Gareth.
|
|
|
|
|
hello frnds,
i have a windows application developed in C#.Net 2.0, i want to transafer a textbox value to anoter form Text how can i do that.
let consider i have frmOne having a textbox txtOne, a button OK, and another form frmTwo
i want to set the value of textbox as a text of frmTwo when i click button Ok
my code is here
//Click event of OK button
frmTwo frtwo = new frmTwo()
frtwo.text = txtOne.text
frtwo.show()
but faliled..
where i am wrong???
please help ????
thankx in advance
-koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Overload form2's constructor which accepts a string value as parameter. Pass the first textbox value to this when you are invoking form2.
frmTwo frtwo = new frmTwo(txtOne.text)
frtwo.show() Inside for2 constructor, assign the value to respective text box.
|
|
|
|
|
|
Please don't do this. If you want to be a better developer, you should learn about design patterns and how they help you design software. You can solve this issue using either the Observable pattern or the Model View Controller/Model View Presenter patterns. Please look at using them.
BTW - it's not Opportunity knoughts softly, it's Opportunity knocks softly.
|
|
|
|
|
I am not getting how it can help in passing one value other form ?
|
|
|
|
|
N a v a n e e t h wrote: I am not getting how it can help in passing one value other form
Because you don't pass values from one form to another. You create a data model and put views on the model. These views get updated when things change. It's that simple.
Suppose you want to extend this issue and have the same value updated in 20 or 30 places, using a pattern makes this trivial. Using hard coded value passing makes it complicated.
|
|
|
|
|
That's great. Thanks. Do you have any good links for MVC implementation on C# ?
|
|
|
|
|
This[^] is a good source of information. This[^] is also excellent - it's very deep and takes a lot of reading, but stick with it.
|
|
|
|
|
Thanks. I will take a look
|
|
|
|
|
I need to pass the IP address to app.config file that is created after installing the project.I got to add the web reference to run my service.
Web reference would be ..
http://202.79.41.240/Setup12/Service.asmx.
Now I need to change the IP address that gets stored in app.config file.
Thanx in advance.
|
|
|
|
|
XmlDocument xDoc = new XmlDocument();<br />
xDoc.Load(@"YOURPATH\App.config");<br />
if (xDoc.DocumentElement.SelectSingleNode("appSettings/add").Attributes.GetNamedItem("key").InnerText == "IP")<br />
{<br />
xDoc.DocumentElement.SelectSingleNode("appSettings/add").Attributes.GetNamedItem("value").InnerText = "genericIP";<br />
xDoc.Save(@"YOURPATH\App.config");<br />
}
But I am not sure how safe it is to handle you app config file in dynamically
Sathy
|
|
|
|
|
Hii All
Could any one please tell me how to insert multiple rows in a single column with single insert statement. I am using MySql Database with C#. Actually i want a structure something like this
JobNum NatureOfComplaint
J001 Changing Tyres
Repairing Engine
Repairing Side Bumper
J002 Changing Engine
Repairing Engine
Touch Painting
I have two columns named JobNum and NatureOfComplaint now i want to
insert one Job Number for example J001 and more than one Nature of complaint under J001 itself as shown above.
How it can be done with C# and MYSQL.
My ultimate goal is i have to create several textboxes at runtime when ever a user clicks of more button one text box should get added and thereafter i want to insert the values from those text boxes to the database.
Any help will be appreciated
Thanks.
Imran
|
|
|
|
|
You can form a single string with some delimiters and insert to the table. But this looks a bad design. You could create two table's where JobNum would be the primary key in the first table and foreign key to the second table. In second table you need to add each row for each NatureOfComplaint .
|
|
|
|
|
The code which i have currently written to insert the values is
try
{
string strInsert = "insert into Quotation" +
"(JobNum, NatureOfComplaint1, NatureOfComplaint2, NatureOfComplaint3)"
+ "values('" + this.txtNatureofComplaint1.Text + "','" + this.txtNatureofComplaint2.Text + "','" + this.txtNatureofComplaint3.Text + "')";
{
MySqlCommand command = new MySqlCommand(strInsert, Quotation.con);
Quotation.dQuotationAdapter.InsertCommand = command;
//Insert new record
Quotation.dQuotationAdapter.InsertCommand.ExecuteNonQuery();
MessageBox.Show("New Record Saved Successfully");
}
catch (MySqlException ex)
{
MessageBox.Show(ex.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
In the above code i want to insert one value for JobNum and three values for NatureofComlpaint from different text boxes. So if there are three textboxes from where i want to fetch the value and store it into a single column of NatureofComplaint then how i will do that.
It always throws an exception that value count dosent match the row count.
How can i slove this issue.
Imran
|
|
|
|
|
Hi,
Recently I have launched a service and it is working fine.
The problem now is it lapses a second for every 2 days.
Is there any workaround to solve this.
Can any one advise me on this.
Long Live
|
|
|
|
|
What do you mean? What lapses a second? What processing is going on? Without this information, I wouldn't even begin to know where to look.
|
|
|
|
|
Hi thanks for you reply.
The service generates a file on a daily basis at a specified time range mentioned in the app config file. For this purpose the service will make a check the current time against the one in config file for every 5 mins.
This part works fine. The problem is for example if it check by 12:34:33 pm the next check is performed exactly at 12:39:33 PM.
But in course of time say a day or two the checking drifts from 12:34:33 PM to 12:34:34 PM. Like this with in a month the polling time chages to 12:35:XX PM.
I wish to put a check on this. B'coz if the file generation time range is between 12:33:00 PM 12:36:00 PM in course of time the service may run without generating the file.
Thanx and Rgds,
Long Live
|
|
|
|