|
ok. i get your point. i check it by removing # with /. i am facing the same problem.
error 31 means--- "A device attached to the system is not functioning."
but device is working properly. how come application is no detecting it correctly???
is my other part of code working fine??? can you please help me in that????
|
|
|
|
|
anuj_jain wrote: i check it by removing # with /.
You really need to a) read my suggestions more closely and b) read up on the format of Windows file and device paths, and C# string constants. Your path should be one of the following:
deviceHandle = CreateFile
("\\\\?\\USB\\Vid_18c8&Pid_2bfa\\063\\{A5DCBF10-6530-11D2-901F-00C04FB951ED}",0, FILE_SHARE_READ |
deviceHandle = CreateFile
(@"\\?\USB\Vid_18c8&Pid_2bfa\063\{A5DCBF10-6530-11D2-901F-00C04FB951ED}",0, FILE_SHARE_READ |
As to reading the rest of your code, I do not have the time or experience to be able to judge it. It is up to you to do your own testing and debugging, a vital part of a developer's job.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
anuj_jain wrote: error 31 means--- "A device attached to the system is not functioning." but
device is working properly. how come application is no detecting it
correctly???
Just because it says that a device is not functioning correctly doesn't mean that it's the device YOU are thinking about. Your code is trying to get at a device using a string that describes something other than what you're thinking. In other words, the device your badly formatted string is pointing at doesn't exist, so yeah, it's not functioning.
|
|
|
|
|
it's my bad that i posted the whole code. i am facing the problem in CreateFile() function.
the code is written below. Moreover, i changed the path and put it into the array variable. so now i think that it is more readable.
The code is as follows:-
deviceHandle = CreateFile(devicePathName[0], GENERIC_WRITE | GENERIC_READ, 0, IntPtr.Zero,
OPEN_EXISTING, 0, IntPtr.Zero);
|
|
|
|
|
i posted the whole code so that one can have a look at whole code. if i am going wrong anywhere, one can point me.
CreateFile() function is failing. i am not able to get the handle to the device for read and write function.
is my other part of the code is fine or i need to change somewhere else also??
|
|
|
|
|
You need to be more specific about the problem. It's not reasonable to expect people to go through your entire test application and debug it for you. If CreateFile is failing it is because you are passing the wrong things to it – I agree with the answer above that says that that path doesn't look correct, and you probably need to look again at how to correctly request a handle to a USB device.
|
|
|
|
|
i had changed the path as told by RICHARD. still i am facing the same problem.
i am facing the problem in CREATEFILE() function.
|
|
|
|
|
Hi All
Iam facing issue while reading the document when runnning code from IIS. It is not reading the document and throwirng an error "No document is opne when trying to save the activedocument.".
m_word.Documents.Open(ref FileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
m_word.ActiveDocument.SaveAs2(ref FileName_rtf, ref FileFormat, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1);
m_word.ActiveDocument is giving error when running from IIS. It is working in visual studio debugging mode.
I also tried the below code. Document doc_open = m_word.Documents.Open(ref FileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); doc_open.Activate();
doc_open is retruning null and it throws object reference error in the second line. this works when code is in debugging mode. Error occurs when ran from IIS on development server where we have IIS 7 and MS offices too.
Please help on this IAm struggling from 5 days.
Thanks in advance
|
|
|
|
|
Hi,
Try making the visible property to true while opening the document , or make the opened document active before saving it.
Like,
doc1.Activate();
|
|
|
|
|
hello guys... I have this datagridview in which I show students. Now when I add more than one students in this grid and update their data, it shows me this error
<pre>Object Can not be Bast From DBNullto Other Types</pre>
Here is the code I am using to loop through and update these students from gridview
<pre lang="c#">
foreach (DataGridViewRow row in dgStudents.Rows)
{
object obj = row.Cells["colStudentId"].Value;
if (obj != null)
{
StudentID = Convert.ToInt32(row.Cells["colStudentId"].Value);
Fee = Convert.ToInt32(row.Cells["colFee"].Value);
NumOfSubject = Convert.ToInt32(row.Cells["colNumOfSubject"].Value);
}
}
</pre>
Even though I check for null values taken from gridview, it still shows me this error. Whats wrong? thnx
-- modified 4-Jan-12 1:04am.
|
|
|
|
|
try this:
if(row.Cells["colStudentId"].Value != DBNull.Value){
...
}
hope this helps.
V.
|
|
|
|
|
Thnx for your time. Actually I had to check all numeric types against null, in the grid.
Then it did not happen again.
|
|
|
|
|
Plus, Int32.Parse and Int32.TryParse are preferable to Convert.ToInt32 -- dont use Convert.
|
|
|
|
|
how to call the database to be displayed,,
through programming asp.net with c#,,
because of problems that came out at compile time
myLayer.DataSource = new SharpMap.Data.Providers.katmai (ConnStr, "dbo.sysdiagrams", "dbo.Geocode", "OidColumn");
please give an example at all,,,
thank you
modified 2-Jan-12 21:08pm.
|
|
|
|
|
I'm sure English is not your native language, but it is the default language for this site.
In English, your question makes no sense at all.
Please, either try to find a better translation of your question to English, or find a site in your own native language, as they may be able to help you better than we can!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
hello friends I work for several months in my hand Makel bi business counters and Kohler have not comport with the remote trying to read them in c # la. and the cable will be connected to a one count. I would say that bi does not like to read one of a few sayacdan. but please do not get the help you lead a more bi olurmusunuz How do I make this work. I give all the settings of the timer in visual studio, how will I am using the SerialPort object. I need to send data to send data to the meter data to come to the counter where the error do you think I give below the meter does not respond to me. If you help too sevinirim. Thank you in advance
string command;
command ="/?!" (char) 13 (char) 10;
byte [] array;
Array = Encoding.UTF8.GetBytes (command);
serialPort1.Write (array, 0, array.length);
|
|
|
|
|
I suggest you start by reading the recent series of three articles on C# serial port programming by Pantelis Chatzinikolis, here on CP:[^].
I also suggest you ask a friend whose English skills are good to help you re-write your question, so it's clearer.
Be sure and tell;
1. the exact nature of the hardware device to which you send information out to by the serial port.
2. does the device that receives information from the serial port of the "transmitter" communicate anything back to the device that transmits: if so, what is that information sent back: and what is the device that receives that information: a server on a network, an individual PC ?
good luck, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
|
i have written the code for filling a treeview with some nodes and subnodes by enabling checkboxes. when a subnode is checked its parent should be checked and when a parent is checked all of its childs should be cheked(like general scenario).
But when i started copying the selected nodes in the treeview1 to new treeview(treeview2)i am getting so many problems. i tried different events to achieve this like NodeMouseClick,treeviewAfterSelect,Aftercheck,AfterExpand but unable to get the required node set (total hierarchy of checked nodes with out repetition and should reflect every change showing and shoud be removed when unchecked )
can any one please help in doing this ?
janardhan
|
|
|
|
|
If you change the way that you think about the problem a bit, you'll find that there's a relatively simple way to solve the problem. Currently it sounds like you are relying on navigating over the view to work out what has been checked, and you are using that to actually perform the update. Now, this is one potential approach, but it's a pretty fragile mechanism.
Rather than approaching the problem like this, why not use an underlying model and use that to control the update? This is the approach that is favoured in developments using WPF, Silverlight and ASP.NET MVC.
|
|
|
|
|
Thanks alot for the reply .You are correct i am relying on navigating on view but i am using windows forms application and i cant use wpf and other environments thats my problem.
|
|
|
|
|
I wasn't suggesting that you change platforms. What I was suggesting is that you could use a pattern such as MVC, and leverage data binding to trigger the update.
|
|
|
|
|
Ok i am new to c sharp i dint used databinding concept. but i will try out databinding to trigger the update .thank you
|
|
|
|
|
It would be good to know if you are using WinForms, WPF, or ? here.
In this case we don't much about the structure of your TreeView: can it have multiple levels of nesting ?
If it can have multiple levels of nesting, and a "child node" three levels deep has its CheckBox checked, then you tell us that all that node's "sibling nodes," and its "parent node" are to have their CheckBoxes checked: but ... then does the parent of the parent node also get all its child nodes, and itself checked ?
Or, is the (as I would assume) "checking" only of the immediate sibling nodes, and the parent.
What happens if the user then unchecks one of the sibling nodes: does that then uncheck all the other sibling nodes ... and the parent ? If the parent node is unchecked: all the sibling nodes are then unchecked ?
Assuming you allow unchecking in the first TreeView: you then need to alter the second TreeView ? ... I'd guess: "yes."
In any case, you can populate a new TreeView by recursively parsing the existing TreeView and creating new Nodes that match those that are checked in the second TreeView, with the same parent/child relationships.
Is recursive parsing of a TreeView something you know how to do now, or can we help with you that ?
And, if your TreeView is only two levels "deep:" a set of root nodes, and each root node having a set of child nodes: then this becomes very easy.
So, some more information about the structure of your TreeView would be helpful.
best, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
|
|
|
|
|
Hi BILL, THANKS ALOT for the reply !!
I am using windows forms application.It can have multiple levels of nesting.
If a node at 3 levels deep is checked only its parent and grand parent are to be checked but not it siblings.
If the user unchecks the a node it has no effect on its siblings but if its parent has no other childs except it then that parent also should be unchecked.
If the parent is unchecked all its childs should be uncheked.
If a node in the first treeview is unchecked it should reflect immeditely in the second treeeview.
Can you help in recursive parsing of treeview you are saying or with any other solution.
|
|
|
|
|
Well, we are making progress in defining the actual structure of your TreeView ... and that's good
This reply raises these questions, for me:
0. is any node in the TreeView ever more than 3 levels deep: in other words: is the level of "nesting" arbitrary ? In other words: is there any regular structure to all nodes that we can assume: for example: they are all 3 levels "deep" ?
1. in the case of one node, which is the only child of its parent: you say the parent should also be unchecked: what about if that parent node is also the "only child" of its parent node: does its "grandfather" then get unchecked ?
a. what if the grandparent node of the only child of the parent node that is unchecked has many other child nodes ... "uncle nodes" ? ... what happens to them: do they get left alone, or unchecked, also ?
2. if a parent node is unchecked: and that parent node has many levels of nested nodes "under it:" do they all get unchecked ... or only the "grandchildren" of that node get unchecked: this would be "symmetric" with the way you now handle unchecking an only child of a node, then its parent, and then its grandparent.
2. is it ever the case that:
a. new nodes are added at run-time ?
b. existing nodes are deleted at run-time ?
To get you started with recursive parsing: put a TreeView on a Form:
0. in the Form Load EventHandler set the 'Expanded property of the TreeView to 'true.
1. edit the Nodes collection at Design-Time, and add a whole bunch of them, nested to various depths
2. set the TreeView 'CheckBoxes property to 'True:
3. put a button on the Form with its Click EventHandler set like so:
private void button1_Click(object sender, EventArgs e)
{
treeView1.ExpandAll();
RecursiveParseTree(treeView1.Nodes, 0);
} 4. And then define the recursive parser:
private void RecursiveParseTree(TreeNodeCollection nodeCollection, int level)
{
foreach (TreeNode theNode in nodeCollection)
{
Console.WriteLine
(
"Node Name: = {0},
Node Level = {1},
Node Checked = {2}",
theNode.Text,
level,
theNode.Checked
);
if (theNode.Nodes.Count > 0)
{
RecursiveParseTree(theNode.Nodes, level++);
}
}
} 5. At run-time check a bunch of nodes at various "depths," and examine the output of running this code in VS's Output Window when you exit the Application.
Discussion: the interesting part is going to be where you get to all the business related to unchecking only-child nodes, and grandparent nodes !
best, Bill
"It is the mark of an educated mind to be able to entertain a thought without accepting it." Aristotle
modified 3-Jan-12 5:25am.
|
|
|
|
|