|
Just use an index on the list:
gotTheArray = objXLIST[0];
---
b { font-weight: normal; }
|
|
|
|
|
Hello,
Method 1: Array theArray = objXLIST[0] as Array;
Method 2: IList theList = objXLIST[0] as IList;
HTH. Cheers.
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
Hi all,
I would like to know how to convert Dataview to a DataSet.
I have a library which takes only DataSet as parameter, and therefore, I need to convert the a Dataview to a DataSet in order to use this library....plz help
Kayne
-- modified at 2:02 Friday 14th October, 2005
|
|
|
|
|
If you already have a DataView (presumably with data "in" it), don't you have the DataSet too?
Can't you just do this:
public DataSet GetDsFromDv(DataView view)
{
if (view != null && view.Table != null)
{
return view.Table.DataSet;
}
return null;
}
DataViews act on DataTables, after all. They're a tool for manipulating the data in tables.
There's no way of creating a brand new DataSet directly from a DataView, but then again, the DataView wouldn't have much meaning without the DataTable and DataSet.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi,
Thanks for the reply
But it is the records in the Dataview that I must pass to my function in my library.
PS: I did a filtering on my Dataset and obtained a DataView like this:
dv = new DataView(ds.Tables["Query5"], "LOAN_TYPE = '10/10/2004'", "",DataViewRowState.CurrentRows);
|
|
|
|
|
First off, you're initializing your DataView twice in the code above:
DataView dv = new DataView();
dv = new DataView(ds.Tables["Query5"], "EVENT_DATE='14/10/2005'","",DataViewRowState.CurrentRows);
...and the answer to your question is no. The method I sent will return the DataSet containing the DataTable upon which the provided DataView is based.
DataSets do not implement filters or custom sorting - they are collections of DataTables, whereas a DataView is a customized view on a DataTable that allows sorted viewing and finer control over what DataRowStates the consumer can "see".
Is this a case where you are wanting to take the results as they appear in the DataView and feed them to this other component that only accepts DataSets? If so, then you could just create a table that matches the view (or original table) and copy the contents of the view's rows into the new table, then pass the table's DataSet into the component in question. I should mention at this point that doing something like that is bound to affect performance, but since you asked:
Example (crude but hopefully effective):
using System;
using System.Data;
class Class1
{
[STAThread]
static void Main(string[] args)
{
DataTable t1 = new DataTable();
t1.Columns.Add("Age", typeof(int));
t1.Columns.Add("Name", typeof(string));
t1.Columns.Add("SomeLetter", typeof(string));
for (int x=0; x<10; x++)
{
DataRow row = t1.NewRow();
row[0] = 10-x;
row[1] = "John " + x.ToString();
row[2] = new string((char)(65 + x), x + 1);
t1.Rows.Add(row);
}
DataView view = new DataView(t1, "Age > 5", "Age DESC", DataViewRowState.CurrentRows);
DataTable t2 = new DataTable();
t2.Columns.Add("Age", typeof(int));
t2.Columns.Add("Name", typeof(string));
t2.Columns.Add("SomeLetter", typeof(string));
for(int p = 0, pc = view.Count; p<pc; p++)
{
DataRow newRow = t2.NewRow();
DataRowView rowV = view[p];
newRow.ItemArray = rowV.Row.ItemArray;
t2.Rows.Add(newRow);
}
Console.ReadLine();
}
}
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thanks a lot turbochimp. That solved the problem for me
|
|
|
|
|
Currently im have 9 projekt in one projekt. 7 of them is generating dll'sa dn 2 is generating exe-files. If a change a dll-projekt, like adding a new function. I compile the whole thing, and i don't get access to the new funktin in the dll. I have to remove the reference to the dll in the exe file projekt and add it again to get it to work. Is there a work around so that i dont have to do this all the time.
Happy coding from Sweden
|
|
|
|
|
Don't reference the dll file, reference the project.
---
b { font-weight: normal; }
|
|
|
|
|
That solved my problem
|
|
|
|
|
Hai every body,
I am working on project related to industrial security.
I have to display the camera input in a windows form.
Is there any control available for live video display in dotnet frame work.
If no control is aavailable in the dotnet frame work please suggest me a good third party control.
Please healp me.
Varmag
varmag
|
|
|
|
|
Hi!
I've a problem...I'm developing an application in which i've to do some drawing stuff. Application is related to Carpet Designing. I created a panel to draw the carpet design on it. When i select to draw a line on it, line is drawn but when i minimize the wonidow and restore it, drawing is lost. Also whenever the paint() is called. Line drawing code is written in MouseMove handler. WHAT IS THE SOLUTION???
-- modified at 23:22 Thursday 13th October, 2005
|
|
|
|
|
You can't just draw things over a panel an expect it to remain there. You draw on the screen, not on the panel element.
To make it work properly, you have to do the drawing from the paint event. Store everything you draw in an array list or something, and redraw it whenever paint is called.
Don't draw anything from the mouse move event, just add it to your list, then invalidate the panel so that it's redrawn.
---
b { font-weight: normal; }
|
|
|
|
|
Hello everyone, I am doing this C# project and I have this problem. I am using the OleDb Database driver to open my csv and dbf files. I have noticed one problem with my connection string, it's that if the directory the file is in has a space in it like C:\D B\ it will not be able to read in the database for some reason. So if that is the directory the .csv or .dbf file is in, that means that C:\D B\ is the dataSource, and for some reason, it does not work. When I renamed the directory C:\DB\, the files were then read appropriately. Does anyone know how to fix this problem?
Sincerely,
The Major Rager
|
|
|
|
|
You could try enclosing the path in quotes. However, I have tried the OleDbConnection class with an Access database (not .csv or .dbf ) with spaces in the path, and I've had no trouble at all.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Your code should look like this
string dbPath = @"C:\D B\" //escape
|
|
|
|
|
Hello, thanks for replying. I already have it like that. It reads in the entire path, and it does connect to the datasource, but when it comes to reading in the Data with the datareader, it doesn't do it. But when I change the directory manually back to C:\DB and the dbPath = @"C:\DB\", it works.
Sincerely,
The Major Rager
|
|
|
|
|
Why does this crash on invalid text? Otherwise it works, but if user input is invalid I end up in a MessageBox "house of mirrors"...
THanks a lot! -> Here's the code....
//////////////////////
////////////////////
void DrawComplexNumber1(Graphics g)
{
Pen p = c_xy.GetNextPen();
p.DashStyle = DashStyle.Dot;
c_xy.SetOrigin(xIndent + graphRect.Width/2, yIndent + graphRect.Y/2);
try
{
cmplxValue1.Real = Convert.ToDouble(textComplex_1Real.Text);
}
catch
{
MessageBox.Show("Error!");
}
try
{
cmplxValue1.Imaginary = Convert.ToDouble(textComplex_1Imaginary.Text);
}
catch
{
MessageBox.Show("Error!");
}
g.DrawLine(p, 250, 250, (float)(250 + (xIndent * cmplxValue1.Real)), (float)(250 - (yIndent * cmplxValue1.Imaginary)));
}
///////////////////
private void complex_1OK_Click_1(object sender, System.EventArgs e)
{
drawLine1 = !drawLine1;
Invalidate();
}
///////////////////////////
//In the Paint Handler
if(drawLine1)
DrawComplexNumber1(e.Graphics);
|
|
|
|
|
Validate the data outside of the paint handler.
Now you are showing messageboxes from inside the paint handler, and when you klick away the messagebox it will cause a redraw of part of the screen, which most likely causes a new paint event in your application. This will put you into an infinite loop.
---
b { font-weight: normal; }
|
|
|
|
|
How can I create and display a form to be topmost to the application only?
The requirements are :
* The form is the topmost window of the application.
* The form should not be topmost to other application and desktop. If the application is not the active application, the form window should not be displayed above the current application.
*The form should be in modeless status. The user can work with the application while the topmost form window is displayed.
A word in simple way, how to create a window like the "Find" dialog in the notepad.exe?
The topmost property in the form class can not work. If it is set to be true, the window will be topmost of everything.
Any expert has some idea? Or provide any clue to a windows API?
Thanks,
leo
|
|
|
|
|
Create the dialog and display it using Show (instead of ShowDialog ). Set it's Owner property to your main form.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
|
If its on mute, i want to unmute it, if its too quiet, i want to turn it up, if its too loud then i want to turn it down, etc.
Any ideas?
|
|
|
|
|
I've never worked with multithreading before in any language.
I'm trying to figure out how to do the following:
I have a function, which generates unique values based on the current time.
It saves the data to a log file.
I have it set that when I click a button, it executes this code.
Rather, what I need to happen is to have it continually execute the function every 60 seconds until I reclick the same button.
I assume I need to use threads to do this. I've looked up several tutorials, but I really can't find an example to do this.
Can someone give me an idea?
Thanks.
|
|
|
|
|
... this is the function I have. The first if clause needs to start a thread which executes the SaveWindow function every 60 seconds. The second needs to terminate the thread. I don't even know if this is the way threads work.
private void buttonScraperControl_Click(object sender, EventArgs e)
{
if (buttonScraperControl.Text == "Start")
{
buttonScraperControl.Text = "Stop";
SaveWindow(); // EXECUTE THIS FUNCTION EVERY 60 SECONDS
}
else if (buttonScraperControl.Text == "Stop")
{
buttonScraperControl.Text = "Start";
// STOP FROM EXECUTING EVERY 60 SECONDS
}
}
|
|
|
|
|