|
I should have included:
-1. keep an open mind; this includes: the compiler is probably right, the programmer most likely made a mistake.
0. apply logic reasoning.
example:
Entry = ev.Entries;
even when the compiler would agree (it doesn't), I as a reader would protest, as the LHS is singular and the RHS is plural.
|
|
|
|
|
Thank you for your patience and somewhat cryptic answers Luc but,
-1. It is (almost) always safe to assume that the programmer has made a mistake. If however he does not know where the mistake is he cannot fix it. Thus he turns to better programmers.
0. Logic is great as long as you can think like the compiler does. I can think in vba but c# is still a learning process. Unfortunately they don't use the same logic<>syntax.
example:
EventLogEntry Entry = ev.Entry; = 'System.Diagnostics.EventLog' does not contain a definition for 'Entry' (same applies to Entries = Entries)
Thank you for your advice Luc but I am just not understanding what you are trying to tell me.
|
|
|
|
|
Look again (closely) at this message: Error 1 "Cannot implicitly convert type 'System.Diagnostics.EventLogEntryCollection' to 'System.Diagnostics.EventLogEntry'"
What is it saying in the most basic terms: cannot convert a [System.Diagnostics.EventLog]EntryCollection (the return value of ev.Entries ) to [System.Diagnostics.EventLog]Entry - OK, you are trying to convert an EntryCollection (a collection is obviously plural) to an Entry (singular). So by changing the destination of your assignment to be some type of Collection (probably an EntryCollection) would maybe get rid of that error. Recompile and see how many of the other errors still exist and follow the same process again. This can be done quite easily without the use of Google just by checking the documentation[^].
You may like to reread Luc's previous suggestion as his logical approach to problem solving will serve you well.
|
|
|
|
|
Maybe it's just a basic misunderstanding of the assignment operator ("="). It assigns the return value of the right hand expression to the return value of the left hand expression. Let's put it in symbols: Target <- Source .
Further down, the lines SMCommand.Parameters.Add() = Entry.Category each call a method Add() and immediately replace its return value by Entry.Whatever . I can only guess, but maybe you want it to behave the other way round.
Add() returns an SqlParameter . Maybe you want to store that via
Entry.Message = Add("@Message", System.Data.SqlDbType.NVarChar, 250).ToString(); But even then, I doubt that EventLogEntry.Category and EventLogEntry.EntryType would accept a string . In this case, you would have to create some kind of conversion.
Ciao,
luker
|
|
|
|
|
i have one issue
whenever selecting radio button ,print option should come by using java script. if any one having solution please let me know.
|
|
|
|
|
You might have better luck posting a JavaScript question in the JavaScript forum. This is C#, and the similarities are superficial.
|
|
|
|
|
this code not sending email Why? please help me
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace Web11
{
public partial class WebSendMail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
MailMessage Mail = new MailMessage();
Mail.To.Add("AotherEmail@hotmail.com");
Mail.From = new MailAddress("MyEmail@hotmail.com");
Mail.Subject = "ASp.net";
Mail.Body = " hi I want Help";
SmtpClient smt = new SmtpClient("smtp.hotmail.com");
smt.Send(Mail);
Response.Write("Email Was Send");
}
catch (Exception ex)
{
Response.Write(" Email Invalid"+ex.Message );
}
}
}
}
|
|
|
|
|
I dont know.
Why dont you
1) Try and debug the code yourself
2) Check the Host name and credentials are correct
3) Post error messages

|
|
|
|
|
Use network cardentials
NetworkCredential authinfo = new NetworkCredential("id", "password");
smtp.UseDefaultCredentials = false;
smtp.Credentials = authinfo;
|
|
|
|
|
Unless they've changed it Hotmail doens't allow relaying, so you can't use it to send emails. You'll need a server that does permit relays.... IIRC, none of the big web-mail providers allow it for obvious reasons
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Enterprise Library ExecuteDataSet method not setting Output parameter value.
The value of output parameter is always null.
using (DbCommand cmd = db.GetStoredProcCommand("s_sProcName"))
{
DataSet ds = new DataSet()
db.AddInParameter(cmd, "@p_sFoo", DbType.String, "Bar");
db.AddOutParameter(cmd, "@po_iOut", DbType.Int32, 4)
ds = db.ExecuteDataSet(cmd);
}
How can i get value of Output parameter?
Can any one please !!
|
|
|
|
|
You are actually giving it an output value in your SP aren't you? That one's caught me out before!
C# has already designed away most of the tedium of C++.
|
|
|
|
|
I need something like this:
private void LoadFieldsNames(string table_name)
{
string[] fields = new string[100];
switch (table_name)
{
case "step_result":
fields = {"ID", "UUT_RESULT", "STEP_PARENT", "LOOP_INDEX", "INTERACTIVE_EXENUM"};
break;
case "uut_result"
fields = {"ID", "STATION_ID", "BATCH_SERIAL_NUMBER", "TEST_SOCKET_INDEX",};
break;
}
comboBoxSelField.Items.AddRange(fields);
}
But i get an error. How can i manage the string propelly?
|
|
|
|
|
try this
private void LoadFieldsNames(string table_name)
{
string[] fields = null;
switch (table_name)
{
case "step_result":
fields = new string[]{"ID", "UUT_RESULT", "STEP_PARENT", "LOOP_INDEX", "INTERACTIVE_EXENUM"};
break;
case "uut_result"
fields = new string[]{"ID", "STATION_ID", "BATCH_SERIAL_NUMBER", "TEST_SOCKET_INDEX"};
break;
}
comboBoxSelField.Items.AddRange(fields);
}
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Thanks a lot - it works! 
|
|
|
|
|
No problem
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Planning to use Microsoft Enterprise Library 5.0 for Data Access in an application.
Here Microsoft.Practices.EnterpriseLibrary.Data Namespace its saying content are outdated, but its latest library.
On many of methods same outdated message appears.
a) Is it OK to use this, Will class/methods works in future?
b) If its outdated then why MS promotes to use/follow patterns ?
c) Are their other alternative, like MS suggest in case of depreciated methods?
regards
|
|
|
|
|
I have a design related question. So please guide me on how to do this?
Right now, I have a xml structure which will be in this format.
<Sheet id="abc"/>
<Elements>
<Element id="xyz">
<value>23</value>
</Element>
<Element id="sdz">
<value>46</value>
</Element>
...
</Elements>
</Sheet>
So, we have a class like this to store each & every element of the sheet.
Sheet
{
Public string SheetId
{
get; set;
}
//all Elements will be stored in the below collection
Public IList<IDictionary<string, string>> Elements
{
get; set;
}
}
But now for few sheets the format has been changed to the below structure.
<abc> //SheetId
<Elements>
<Record>
<Element1/>
<Element2/>
<Element3/>
<Element4/>
</Record>
<Record>
<Element1/>
<Element2/>
<Element3/>
<Element4/>
</Record>
...
</abc>
So, we need to create a Generic class to hold the above xml formats and we don't want to have different object to store these.
I mean in future if we have some other xml format also we need to accommodate the same without any change in the Sheet class.
Ok. let me explain how my app works.
Actually we have around 200 sheets(in other words measures).
1) User will upload the sheet data in xml format (all sheets in xml file) & edit the same if they want Or Enter the data in the screen (dynamic screen generated using the xml template) if they dont want to upload.
2) Then the data will be stored in the Sheet object and it will go through lot of Validation process and finally the data will be converted to xml again and stored in the db.
You can ask why you want to store this as XML? The reason is we dont want to create 200 aspx pages for this same kind of data and thats why we are generating the sheet pages dynamically using the xml templates. Also, we will be adding, updating or deleting sheets frequently.
Ok. I think now you will have some idea about this issue.
To be more clear, all the elements in my XML file will be displayed as a field in the aspx page. It maybe a Textbox, dropdown & etc....
So, can anyone please advise me on how to design the Sheet Class.?
|
|
|
|
|
Since the goal should be to handle all of the files the same way, you could:
0) Write some code to import/convert the old files to the new format.
1) Write some code to handle the difference, but in the end create the same objects regardless of incoming format.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
You have a 'design' problem not a "class design" problem.
Right now your architecture looks like the following.
xml/objects => business functionality.
The problem with that is that you now want to coerce all possible models into something that is difficult now and possibly impossible in the future.
Your architecture should look like the following.
xml => transform/map => business objects => business functionality.
If it did then all you would need to do would be to add another 'transform/map' for each new form that the xml takes.
|
|
|
|
|
I am working on a project, as the beginning, my program must allow user to draw 2D shapes ( like windows paint or (more professional) 3dsmax ).
I try drawing a grid by calling a function from form' load event. (its not working well , it draw sometimes and sometimes not !! )
I try using mouse_move, mouse_down, mouse_click events of my form to call proper functions for drawing user specified shapes. ( its not working well either. )
because I will have a lot of shapes, I could not use the onPaint event and put all my drawing codes there , cos it will result in screen blanking and I am not satisfied with that.
So, for example one of my main problems with my specified method is this :
I use click-and-move method for drawing shapes, Does anyone knows how I can use this method more effective ?
Or is there any way to do this more fast and reliable ?
|
|
|
|
|
The one correct way is by putting all the painting code in the Paint handler. Here[^] is an article giving theory and an example.
You should describe your drawing elements in some data structures; there are lots of examples around, look for CP articles that have "Paint" in their title, or Google for "Paint.NET".
|
|
|
|
|
You *SHOULD* use WPF. WPF is very conducive to what you want to do. In fact, it will do 90%+ of what you have described out of the box with almost no effort from you. If you do not use WPF, well, you are going to be writing a lot of code yourself thats already been written by the WPF team .
|
|
|
|
|
well , I used WPF for one of my projects before, you are right it has a lot of advantages which are geart !!
But for this project, WPF MAY seem to be useful for GUI part, but for AI part of my project WPF is weak, or better say its so hard to do what I want in WPF.
|
|
|
|
|
That makes absolutely no sense. If WPF makes fully half of your job easier, WPF is probably the way to go. I have a feeling that down deep, you know this to be true, but you're fighting it. That's not going to do anything but hold up the project and pissing off everyone involved.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|