|
Dear friends
I have one datagrid which has data from one of the table as employee_master.
on click of any record on the grid I want to get the value of first cell that is employee code. but when I clicked first time it does not give me any value. on second time click it gives me the value. How can I get the value of the cells which I need in first click only.
Your quick response will be highly appreciated.
Thanks
Murtuza
|
|
|
|
|
Should you work with a dataGridView, try to treat other events like CellClick or CellMouseClick
SkyWalker
|
|
|
|
|
As an expansion to this, use a DataGridView and a BindingSource. It provides superior data management capabilities. Search the CP articles for a good one on data binding and the datagridview
|
|
|
|
|
Hi
Again I have one more problem in SSIS package. I have separate component it works well for sql to sql if i try to tranfer from oracle to oracle it gives error while converting unicode to non-unicode.
I am hanging to this problem for nearly 2 days. Help me please
kesavan
|
|
|
|
|
Try open your package and set the data type of your working field(s) to be DT_WSTR
SkyWalker
|
|
|
|
|
Hi
I am trying to create one ssis pacakage programmatically in c#. It is working for sql to sql. If i try to tranfer data from sql to oracle it is giving error while reinitializingmetadata. Getting error while creating destination connection. Could any body help me please...........
kesavan
|
|
|
|
|
how to change color of the selected or pointed node in a tree
view control.
i know about the selectecd node property...but in this case i cant use it.
Thanks in advance
shaz jazz
|
|
|
|
|
If you want to do something to the selected node, you *need* to use the selected node property.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
For example:
<br />
YourNode.BackColor = Color.Green;<br />
YourNode.ForeColor = Color.White;
SkyWalker
|
|
|
|
|
Hello all!
I would like to write a method like this:
public static T Sum<T>(T[] data)
{
T s = default(T);
if(data.Length == 0)
throw new ArgumentException("No data!");
for(int i = 0; 0 < data.Length; i++)
{
s = s + data[i];
}
return s;
}
Unfortunately this code doesn't work.
Compiler Error: The operator "+" can not be applied to operands of type "T" and "T".
What's wrong? Are there any constraints to apply?
Thank's in advance!
*************************
Do, ut des.
|
|
|
|
|
The compiler can't guarantee that 2 objects of type T have a + operator defined.
What if T was a MySQLConnection for instance?
I just did a google for generics c# operator and look what came up:
http://www.codeproject.com/csharp/genericnumerics.asp
haven't read the article but probably worth a read.
HTH
Russ
|
|
|
|
|
Thank you. I will read the article and post valuable results.
*************************
Do, ut des.
|
|
|
|
|
You can use the where T : format to specify what T needs to be. I don't know if you can specify that T impliments operator +, tho. Generics are very dumb, compared to C++ templates.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Thanks! I think this a todo for future releases of .NET...
*************************
Do, ut des.
|
|
|
|
|
I'm trying to load an image into a byte array. The following code seems to be OK for the moment but i'm worried that it's not right.
FileStream fs = new FileStream(FileName,FileMode.Open);<br />
byte [] ImageData = new byte[fs.Length];<br />
fs.Read(ImageData,0,(int)fs.Length);
Firstly, while i can't see anyone loading files bigger than int.MaxValue any time soon, it's always nice to future proof your code and someone might load a video that big, even today. For the application I'm using it for I'll probably block files over about 10 Meg anyway so I can ignore this issue.(I might stick in a LATER: comment and come back to it)
Second and of more immediate concern is that I read somewhere (but have now lost the link) that fs.Read will block until it has some data, not necessarily all the data in the stream.
Is my simple code OK or should I be checking whether the stream is fully loaded before i do things with the data? It seems to work allright at the moment but this is a reasonably fast machine with good disks and not much swap file use.
Russell
|
|
|
|
|
Looks fine to me. You want the image file, in it's encoded format, right ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I'm putting the file into a DB so as long as it's a valid byte array I hope it'll be OK when i get it back out again.
Was just a bit worried that the webpage i read yesterday used about 20 klines of code to achieve the same result.
Thanks for your swift reply
Russell
|
|
|
|
|
The Read method returns an integer that contains the number of bytes read. You should check this value to be sure that all the data was read.
From the documentation on the Read method in MSDN:
"The Read method returns zero only after reaching the end of the stream. Otherwise, Read always reads at least one byte from the stream before returning. If no data is available from the stream upon a call to Read, the method will block until at least one byte of data can be returned. An implementation is free to return fewer bytes than requested even if the end of the stream has not been reached."
If you are using framework 2, you can use the File.ReadAllBytes method.
---
Year happy = new Year(2007);
|
|
|
|
|
I think you are right about fs.Read blocking for at least some data
The doc says "Returns the total number of bytes read into the buffer. This might be less than
the number of bytes requested if that number of bytes are not currently available, or zero if
the end of the stream is reached."
So returning zero because nothing is available yet seems not to occur, hence a wait for data.
Whether you can go on with partial data is entirely up to you (do you need all data, or
just enough to figure out the image size, a thumbnail, ...). You may have to take
the return value of fs.Read into account.
If you need to be sure all data is available, but dont want to wait for it, consider
working asynchronously (with BeginRead).
Luc Pattyn
|
|
|
|
|
Looks like readallbytes is about to become my friend, thanks for that I hadn't noticed it before.
Russell
|
|
|
|
|
Documentation promises an UnauthorizedAccessException for a read-only file
Luc Pattyn
|
|
|
|
|
Read only file is only one of the causes of that error.
The process might not have permissions to read the file for instance.
Russell
|
|
|
|
|
Sure, I am just saying
1) I dont understand why Read should fail on read-only files
2) you may have to read a read-only image file, for which File.ReadAllBytes would fail
Luc Pattyn
|
|
|
|
|
So I tried it on a read-only file, and it works.
I'm still puzzled why the doc mentions read-only as a possible cause for
UnAuthorizedAccessException.
It does not mention it for File.OpenText, OK
it does for File.OpenWrite, OK
it should not for File.ReadWhatsoever !
Luc Pattyn
|
|
|
|
|
I assume that the doc has been created by an automated process and 1 has been ammended later and the other not. The inconsistency with the other methods is bizarre but not unusual for MS.
Russell
|
|
|
|