|
It say's Invalid command for CMD
|
|
|
|
|
Try renaming the text-column; it's probably a reserved word.
|
|
|
|
|
Is there any other way in assinging variables?
|
|
|
|
|
Nope.
Still, I don't think the code is faulty; it's more likely to be the Sql command. A column named "TEXT" might be confusing to the parser.
|
|
|
|
|
Today the ports were getting confused and Win'7 was lying to me again.
I first removed the device (Control panel ---> Devices and Printers ---> removed the external device which was connected by BlueTooth.)
I then went to device manager, and deleted all the ports that I knew were bogus.
I then went back to Devices and Printers
I added the known device.
Windows reported that COM20 was back on the list.
There were a total of 4 Com Ports
COM1
COM2
COM18
COM20
Within a few minutes, I watched, king of the clueless, as Windows started adding more Com ports, specifically,
COM25
COM28
COM29
COM30
Following this, Win'7 begins lying to me again, telling me that I have two COM20 ports.
This was exactly and precisely the same problem I had which kept me chasing clouds for 10 days, and I do not want to repeat the previous behavior.
There are a total of 4 USB devices connected to this machine
One USB Hub with three devices attached
-- A debugging device for the embedded system
-- An external hard drive
-- The bluetooth device
There is one other USB cable connected to thin air
What on earth is going on ?
Why is Win'7 reporting two COM20 ports ?
I welcome and thank anyone who can provide any answer behind all this.
|
|
|
|
|
You need to ask this in the hardware forum. This has nothing at all to do with C#.
|
|
|
|
|
Sorry, NewBee NoClue, Mods ? Can you move this ?
Can I ?
|
|
|
|
|
I must be slipping. This used to work...
The XML file:
<?xml version="1.0" encoding="utf-8"?>
<Properties>
<PropertyEditor>
<Property ViewName = "Characteristics" PropertyName = "ValueLand" DisplayName = "Land Value" DataType = "numeric"/>
<Property ViewName = "Characteristics" PropertyName = "ValueStructure" DisplayName = "Structure Value" DataType = "numeric"/>
<Property ViewName = "Characteristics" PropertyName = "ValuePersonal" DisplayName = "Personal Value" DataType = "numeric"/>
</PropertyEditor>
</Properties>
and the code to read it
private void GetPropertyData()
{
propertyDatas = new List<PropertyData>();
string path = Path.GetDirectoryName(Application.ExecutablePath) + @"\EditorProperties.xml";
XmlTextReader reader = new XmlTextReader(path);
XmlDocument doc = new XmlDocument();
XmlNode node = doc.ReadNode(reader);
foreach (XmlNode childNode in node.ChildNodes)
{
foreach (XmlAttribute att in childNode.Attributes)
{
PropertyData propertyData = new PropertyData
{
ViewName = att.Attributes["Characteristics"].Value,
PropertyName = att.Attributes["PropertyName"].Value,
DisplayName = att.Attributes["DisplayName"].Value,
DataType = att.Attributes["numeric"].Value
};
propertyDatas.Add(propertyData);
}
}
}
Now, for some reason, it reads the 'XML' line, then the code skips out on the first foreach.
What's wrong here?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: What's wrong here?
I cannot say whether or not this used to work; but when debugging, it tries to iterate the children of the first element. The first element being the <xml> tag, and it has no children.
XmlTextReader reader = new XmlTextReader(path);
XmlDocument doc = new XmlDocument();
reader.MoveToContent();
XmlNode node = doc.ReadNode(reader);
http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.movetocontent.aspx[^]
|
|
|
|
|
That's exactly what I said in my post.
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: That's exactly what I said in my post.
In that case, it would have been a duplicate. Did you do any updates? (Software-updates, VS, Automated Updates, MSXML?)
Could it be that your Xml "used" to simply not have the first line in there? In that case, the code would have worked, as is.
modified 5-Nov-12 16:59pm.
|
|
|
|
|
Somehow got your attribute names screwed up:
PropertyData propertyData = new PropertyData();
{
propertyData.ViewName = childNode.Attributes["ViewName"].Value;
propertyData.PropertyName = childNode.Attributes["PropertyName"].Value;
propertyData.DisplayName = childNode.Attributes["DisplayName"].Value;
propertyData.DataType = childNode.Attributes["DataType"].Value;
};
|
|
|
|
|
I am not sure how to do this and need some help....
I have a couple of functions that are identical other than one input parameter, signatures look like:
public void Func(Dictionary<string, int>)
public void Func(Dictionary<int, int>)
these end up calling the same functions with different signatures, but as I said, do the same thing.
What I want is to combine them both into 1 function that handles both cases.
Can it be done, and if so how?
Thanks!
|
|
|
|
|
"What I want is to combine them both into 1 function that handles both cases. Can it be done, and if so how?"
Implement the string version, then convert the ints into strings to use it with ints.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Maybe. But C# generics aren't C++ templates - you can't call two different overloads of a method based on the concretization of a generic type, because the concretization doesn't happen at compile time.
It would look like this:
public void Func<T>(Dictionary<T, int> somename)
But going by the description, there's a good chance you can't do this (or actually you could, but you'd have to manually test the type of T, and that's arguably a worse situation than you're on now).
|
|
|
|
|
I'd suggest looking at whatever part(s) of the functions that are truly identical (including types) and factoring that logic out of the two specific implementations, into a (private) sub-function.
Or use the generic implementation as suggested by Harold.
Either way, be careful to avoid falling back to an object -based (non-generic) implementation, because boxing-unboxing will impact your performance.
|
|
|
|
|
Hi,
With my Form_Load() I wish to set my 150'th Row as my TopRow, while the DataGridView gets visible. For that when I setup the currentcell Property its working fine. no prolem.
But when I try through the FirstDisplayedScrollingRowIndex() property its not working.
Its Not Working
dataGridView1.Rows[150].Selected = true;
dataGridView1.FirstDisplayedScrollingRowIndex = 150;
dataGridView1.Focus();
But the below is working
dataGridView1.Rows[150].Selected = true;
dataGridView1.CurrentCell = dataGridView1.Rows[150].Cells[0];
dataGridView1.Focus();
THANKS
|
|
|
|
|
Searched here on www.CodeProject.com
Searched the internet with Bing, Google, Yahoo, I forget whom else.
This was about what I found...
"Getter", noun: [1] A person or thing that gets, [2] stuff that's sprayed on the inside of vacuum tubes
The word is used frequently here on CodeProject. If it is defined somewhere with examples (in C#) then please point me to it.
Thanks
|
|
|
|
|
|
Thank you, for both the examples, and the description of how to find the answers on my own. I believe that I used a similar method for searching for the answers.
The first two examples left me saying "Duh"
The third example helped a little. I still don't have a clear definition in my head of just exactly what "Get" and "Set" are doing in terms of what byte goes where.
So, C# has this new way of setting values ? With the GET and SET thing ?
Please forgive my lack of vocabulary and nomenclature.
This is the way I had been thinking...
private void Button1_Command_01_Click(object sender, EventArgs e)
{
try
{
The_Action_For_Button1(The_Data_For_Button1);
return;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
But I'm off track with that kind of approach ?
What I'm after is an interface where the user clicks a button and the machine sends that command out the serial port. Currently, I'm trying to figure out how to arrange one method in one file to be visible to other methods in other files so that I can call the method from other methods in other files. (e.g., like subroutines in other languages)
C# has some sort of structure and rule system which is preventing me from doing that at this moment.
I'm still experimenting; will try the static word (suggested by another member in another thread earlier) in a few minutes from now.
modified 12-Nov-12 12:23pm.
|
|
|
|
|
|
in C# getters and setters are just syntactic sugar for get_Propertyname() and set_Propertyname(value) methods.
Think of a customer
public class Customer
{
private string name;
public string Name
{
get{ return this.name; }
set{ this.name = value; }
}
}
Usage
var cust = new Customer();
cust.Name = "Jamie";
MessageBox.Show(cust.Name);
|
|
|
|
|
Getters and setters are synctactic sugar. Behind the scenes, they map to special get_ and set_ methods. Okay, that sounds complicated, so let's have a look at what this statement actually means. Suppose you have a string property called BodyText. In C#, this would look something like this:
public string BodyText
{
get { .... }
set { .... }
} What the compiler does with this is to create 2 methods, set_BodyText and get_BodyText which would look something like this:
public void set_BodyText(string value)
{
...
}
public string get_BodyText()
{
return ....
} If you use reflection, you can actually find these methods. They are hidden from you in Intellisense because these methods (in the underlying IL) are marked as hidebysig specialname .
|
|
|
|
|
Pick up a book on C# and read - you would get an idea on properties and setters - getters.
|
|
|
|
|
Okay, so it's all about the learning curve ?
So then, like, C# takes a long time with repeated experiments and examples and so on before you are really competent to write something useful ?
|
|
|
|