|
Hi!
I'm having some problems in my code. I want to get values from a datareader to a double[]. I have read the values to an array list, this is my code:
int counter = 0;
ArrayList al = new ArrayList();
while(dtr.Read())
{
object[] values = new object[dtr.FieldCount];
dtr.GetValues(values);
al.Add(values);
counter = counter++;
}
If I write al it returns the correct values, but I can't get theese values in to a double. How can I do this? Is it maybe easier to put the values directly from the datareader to the byte array?
Thanks!
|
|
|
|
|
hi,
your question is not clear. I don't understand what exactly do you want...
Well here are the 2 possibilities that I can think of...
1st Possiblity :
If you require a specific Array of type object from the arraylist then you may use a similar code as below
string[] s = new string[10];
s[0] = "Aryadip";
ArrayList al = new ArrayList();
al.Add(s);
string[] ss = (string[])al[0];
MessageBox.Show( ss[0] );
2nd Possibility :
You require the full arraylist content in an array...in other words the array representation of the arraylist.
Now the complexity is the arraylist elements are arrays
Then the resulting array will be double dimentional...
The code to retrieve the same is :
string[] s = new string[10];
s[0] = "Aryadip";
ArrayList al = new ArrayList();
al.Add(s);
string[][] ss = (string[][])al.ToArray(s.GetType());
MessageBox.Show( ss[0][0] );
Now tips for your code :
DataReader is returning you an object array. After adding that object array to arraylist(like you did) you can get them back by using one of the methods mentioned above(replace string with object).
In the Individual object arrays that you add to the arraylist... if all the values are of type double then you can safely typecast with double array.
In case you are not sure or the object array contains values from different datatype then first obtain the object array by using one of the above methods and then use "Convert.ToDouble()" method to convert the specific array element to double value.Please refer to code below to get a better understanding...
object[] s = new object[10];
s[0] = "Aryadip";
ArrayList al = new ArrayList();
al.Add(s);
string[][] ss = (string[][])al.ToArray(new string[10].GetType());
MessageBox.Show( ss[0][0] );
Hope this helps you... if I have gone into wrong track... then sorry for that...
regards,
Aryadip.
Cheers !! and have a Funky day !!
|
|
|
|
|
Hi
I don't think that you understood me correctly, I'll try to explain it better this time. I want to get values from my db (that I have done). There are at the most 100 values, but there can also be less, but they are all in the same formate (numbers). I want to put theese number in to at double array so I can write them out in a graph.
Thanks again!
|
|
|
|
|
If you want to read doubles from a DataReader like a SqlDataReader , then use SqlDataReader.GetDouble (these types of methods are declared on DataReader derivatives). If each field is a double, then continously read through your DataReader like you're doing, but then iterate over the field count and read those doubles into an array. You can either use an ArrayList or use a multi-dimensional or jagged array.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi wizzards and all!
In the MS-Help is allways a blue banner with title.
I'd like to have the same in my html-helpfiles. Is there an example how to do it?
Ariadne
|
|
|
|
|
Right-click and click "View Source". There's your example.
If you want to generate MS-Help like code documentation, then use NDoc[^]. We went to a lot of work to provide help files that work like MSDN (both old an new) and provide other documenters as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
>Right-click and click "View Source". There's your example.
No, there is a link to some 'occult' files.
I look for a snipped, which makes the blue banner.
Thanks
Ariadne
|
|
|
|
|
Trust me - it's in there. How do you think we on the NDoc team got ours to look the same?
It's this block of HTML plus styles defined in the linked stylesheet:
<div id="nsbanner">
<div id="bannerrow1">
<TABLE CLASS="bannerparthead" CELLSPACING=0>
<TR ID="hdr">
<TD CLASS="runninghead" nowrap>.NET Framework Class Library</TD>
<TD CLASS="product" nowrap> </TD>
</TR>
</TABLE>
</div>
<div id="TitleRow">
<H1 class="dtH1"><A NAME="frlrfsystemexceptionclasstopic"></A>Exception Class</H1>
</div></div>
Use the relative path to the CSS file to see the source for that, which is easy enough. The styles to look at are #nsbanner, bannerparthead, runninghead, product, and dtH1.
<div style="width:100%;font-size:2px;margin-bottom:-10px;background-color:#FF9900;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1,StartColorStr=#FFFF9900,EndColorStr=#FFFBEDBB);"> </div>
Microsoft MVP, Visual C#
<a href="http://www.codeproject.com/script/articles/list_articles.asp?userid=46969">My Articles</a>
|
|
|
|
|
Hi all,
I created some drawing objects, which draws image on the screen by itself. I'm using graphics drawing method inside, for example; Graphics.Draw(), Graphics.DrawRectangle() etc.
I want to ask, is it possible to draw them with OR transparency? because sometimes, they can be overlapped.
How can I solve this problem ??
Thank you for your help....
|
|
|
|
|
If I don't make mistake , when you set your Pen or Brush from a Color structure , you can set it with Color.FromArgb method. You have to set its first argument. (alpha)
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Thanks for reply,
I know we can get Pen / Brush with alpha setting, but Graphis.DrawImage() does not contains alpha setting.
g.DrawImage( image, location);
the main problem is when I drawing some image on screen, it can't draw as transparency. Is there a way to set the alpha of Graphics property??
|
|
|
|
|
I think if you first draw your image , then you can draw your other objects like rectangle with this option and use transparency. Search for GDI+ articless in this site, maybe you get better solutions there.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
For Xor drawing, you want to look into Regions[^]. See the Region documentation here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
hi
why this code dosnt work.
<br />
Graphics g = Graphics.FromHwnd(IntPtr.Zero);<br />
g.DrawLine(new Pen(Color.Red),50,50,500,500);<br />
g.FillRectangle(new SolidBrush(Color.Red),10,10,250,300);<br />
thanks
|
|
|
|
|
hello,
i have created a MDI form that contain two child forms
class ParentForm : Sytem.Windows.Forms.Form
{
........
void func()
{
this.IsMdiContains = true
ChildForm1 child1 = new ChildForm1();
child1.MdiParent = this;
child1.Show();
ChildForm2 child2 = new ChildForm2();
child2.MdiParent = this;
child2.Show();
}
my question is : i want to show both child1 and child2 and i`m using the next statement:
this.LayoutMdi(System.Windows.Forms.MdiLayout.TileHorizontal);
but the problem is that i dont want to see on the screen half from ChildForm1 and half from ChildForm2. i want to see the real size form definition of both Child forms. what should i do?
thank you
koby
|
|
|
|
|
You could try MdiLayout.Cascade instead and see if that layout works for you. If not, then you'll have to write your own code for laying out the child forms the way you want.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hai there,
when ever i created setup in vs.net Ide i am getting this error mesage,
C:\DOCUME~1\user\LOCALS~1\Temp\VSDA6C.tmp\Managed.D93ED6F5_1D53_11D4_A53C_0090278A1BB8\Program Files\Microsoft Visual Studio .NET 2003\Crystal Reports\Viewers\images\Tree\singleminus.gif' 'Interface not registered'
C:\Documents and Settings\user\Desktop\essdf\Setup1\Setup1.vdproj Could not find file 'C:\Documents and Settings\user\Desktop\Tops Planner Version 1.0.0 Source Freeze On 8- June- 2004 12 Am\12-13FT.ico' 'Interface not registered'
C:\Documents and Settings\user\Desktop\essdf\Setup1\Setup1.vdproj Could not find file 'D:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\Deployment\.\MsiRedist\1033\MsiLoadr.Bin' 'Interface not registered'
What is this 'Interface not registered'
any idea?
Please feel free to contact.
Sreejith S S Nair - Bangalore
|
|
|
|
|
I am looking for good .NET Profiler. Which do you use?
Wizard_01
|
|
|
|
|
|
Hi,
I am trying find the services which are running on my machine on polling basis, and I am trying write this to a file before shutdown. I am trying to do this using a service, I am writing the code for file writing in the OnStop() method of the service. The problem is my service starts and stops immediately. Why this is happening??
Code Snippet:
OnStop()
{
System.IO.StreamWriter file = new System.IO.StreamWriter("d:\\test.txt");
Process [] curentProcess= Process.GetProcesses();
foreach(Process p in curentProcess)
file.WriteLine(p.ProcessName);
file.Close();
}
Regards,
Satya
|
|
|
|
|
SatyaDY wrote:
my service starts and stops immediately
Your service does not even reach OnStop(), the problem is Main() or in OnStart().
To locate the failure, check the event log. Are there any exception messages from your service?
If not, you can write a log file during OnStart(), to see where the service stops.
|
|
|
|
|
check the event log
Yeah, I checked the event log, it's having entries for start and stop.
When I comment the code, for file opening and writing, I find it running without any problem. How the file writing of the process names giving the problem I couldn't get.
Regards,
Satya
|
|
|
|
|
ummm... I don't really have a solution to your problem, but I think I see a problem with your service. Basically, in order for your service to work, it has to be the first service to stopped during shutdown, else the GetProcess Method won't return those processes stopped before hand.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
|
|
|
|
|
I think you are correct. Because the GetProcess couldn't get the Processes, file writing is also failing and the service is stopping immediately. Can we give priority (for making it first to stop)??
Regards,
Satya
|
|
|
|