|
I want to write a subroutine which fetches data from a database, save column to a hashtable (columname=columnvalue) and then put each dataset hashtable into an array ... then i want to return this array to the main program and run through each element and dereference the element back to a hashtable ... in perl i know how to do this - but have no clue how this had to be writen in c# ... (perl: %hash = %$array[element])
i trie something to put a hashtable into an array of string[] but i don't know how to get the hash back from the element of the string[] ...
Thanks for your help!
Matthias
|
|
|
|
|
This may seem obvious, but have you tried System.Collections.Hastable? If you are working with only strings, the System.Collections.Specialized.NameValueCollection may offer better performance..
|
|
|
|
|
HashTable[] ha = new HashTable[number_of_elements_in_array]();<br />
<br />
HashTable h = new HashTable();<br />
h.Add(key, value);<br />
<br />
ha[array_element_number] = h;<br />
Now you pass your ha array around, and get the hashtables back like this:
<br />
HashTable h = ha[array_element_number];<br />
If you defined your array in another way, like object[] or so, you will have to do a cast when retrieving the hashtable.
|
|
|
|
|
Thanks Arjan - works fine!
|
|
|
|
|
Sounds like your trying to apply Perl design to a C# program. Before you go too far, you should first try to understand the database access classes in the System.Data namespace. A DataTable acts a lot like an array of DataRows, where individual fields can be accessed by name.
But if you really want something like a perl array of hashes, it might look like this:
using System.Collections;
...
ArrayList a = new ArrayList();
Hashtable h = new Hashtable();
h.Add( "One", 1 );
h.Add( "Two", 2 );
a.Add( h );
h = (Hashtable)a[0];
Console.WriteLine( h["One"] );
Burt Harris
|
|
|
|
|
I have a Form with a toolbar. The toolbar contains some Buttons with Text like "&New", "&Edit", ...
I meant that marking the Buttons as HotKey is enough to allow access via ALT+"N", ALT+"E", ...to fire the ClickEvent.
So how is it possible that Toolbar Buttons react on Keyboard Inputs like normal Buttons with HotKey?
Thanks
Stefan
|
|
|
|
|
I want to write a LinkList Libary use "Template", but I must write in C# and C# doesn't have "Template"! How do I do? or How can I do? thx!
|
|
|
|
|
No, but it will do, maybe in the next release.
As an aside while they are called templates in C++, they will probably be refered to as Generics in other languages e.g. Java - which has just had them added in 1.5.
As for LinkList, have a look at the .NET collections classes under "System.Collections".
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
Since we have to wait for Whidbey (.NET 2) for true Generics to be implemented, I read an interesting article on GotDotNet.com about using a basic version of Generics by using objects. Since all entities in .NET derive from the Object class, anything can be boxed as an object.
Visit
http://www.gotdotnet.com/team/csharp/learn/Future/VCS%20Language%20Changes.aspx[^]
And look under "Building Generic classes today"
"I have a strange ginger man living on my roof!"
"One of the most important things you learn from the internet is that there is no ‘them’ out there. It’s just an awful lot of ‘us’."
-Douglas Adams
Jonathan 'nonny' Newman
Homepage [www.nonny.com] [^]
|
|
|
|
|
Hello!
I want to import DBF file and to bind DataGrid in WinForm.
Is there anybody who knows bind DBF file with DataGrid?
Thanks!!
I'm not who I was
|
|
|
|
|
bania wrote:
import DBF file
Are you referring to a "Data Base File", "DBase" file, or another type of file? If you are referring to some form of database, simply use ADO.NET. Even the wizards in VS.NET (if you have that) will build most of that for you. In the constructor for the form after the call to InitializeComponents, add in the code to fill a dataset and bind it to the gird.
Many examples on CP for that.
Rocky Moore <><
|
|
|
|
|
I have a strange problem... If I launch a standard CommonDialog (OpenFileDialog, SaveFileDialog, ColorDialog), afterwards my buttons' Click events are never fired. It's odd, as I can see that the button is receiving the click (it's visibly pushed down), but the event handlers are never called.
Similar code works in a standalone Windows Forms application, so I think it is something specific about the BandObjects library or the context of a band object. Any possible ideas?
Thanks,
Arun
|
|
|
|
|
To be more accurate, I'm referring to the ToolBar not firing the ButtonClick event.
|
|
|
|
|
Hello,
I got a problem.
I've made a FolderTree by using TreeView control. Now, I want to search one node that represents the user typed directory path in textBox.
I have no idea to do this. How can I search that node.
e.g. user typed : C:\folder1\temp
then the tree control expanded at temp.
Please Help, and could anyone show me some example??
Thank you very much!!
|
|
|
|
|
Here are a little approach ...
<br />
public TreeNode Search(TreeNodeCollection col)<br />
{<br />
IEnumerator myEnumerator = col.GetEnumerator();<br />
TreeNode node = null;<br />
while(myEnumerator.MoveNext())<br />
{<br />
System.Console.Out.WriteLine(((TreeNode)myEnumerator.Current).Text + ": "+ ((TreeNode)myEnumerator.Current).FullPath);<br />
<br />
if ( ((TreeNode)myEnumerator.Current).FullPath == textBox1.Text)
return ((TreeNode)myEnumerator.Current);<br />
else<br />
{<br />
node = Search( ((TreeNode)myEnumerator.Current).Nodes );<br />
}<br />
}<br />
return node;<br />
}<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
TreeNode node = Search(treeView1.Nodes);<br />
if (node!=null)<br />
{<br />
treeView1.SelectedNode = node;<br />
treeView1.Select();<br />
} <br />
}<br />
I hope that it helps.
Greetings, Jose.
|
|
|
|
|
Oh~, Really thanks. I've got idea how to do this...
|
|
|
|
|
need to supply the version number of my .exe in a Help/About dialog... tried using "Assembly.GetExecutingAssembly" static function which gives the version number in a string along with some other attributes, but I'm sure there's a better way of obtaining your own version number...???
thanks for any help...
|
|
|
|
|
Assembly.GetExecutingAssembly().GetName().Version
<a TITLE="See my user info" href=http:
|
|
|
|
|
hi there,
I am a new kid in the block . Today, I have tried my very first program in ASP.NET using C# language. Let me try explaining what am i doing here. I have created 2 text boxes and one text area in a webform and entering values in those fields and trying to display those values in the same web page. But it is displaying an error on the internet explorer.
You can see the error discription underneath
Compiler Error Message: CS0246: The type or namespace name 'spanComment' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 4:
Line 5: void Submitbtn_click(Object sender, EventArgs e){
Line 6: spanComment.InnerHtml = "Here are the details we received:<BR/><BR/>" +
Line 7: "First Name : " + firstname.text + "</br>" +
Line 8: "Last Name : " + lastname.text + "</br>" +
Source File: C:\Inetpub\wwwroot\asp.net\submitreceivecomments.aspx Line: 6
I am very bad in explaining things but i tried my best explaining where am i strucking at . Please help me solving this .
thanks in advance.
Dev
|
|
|
|
|
The compiler is barking at you because it can't determine what type spanComment is. It is probably because you are missing a "using" directive or a reference.
You'll need to determine what class you've derived spanComment from and ensure you have the proper using directive in your code module. You also need to make sure you've set a reference to the proper component/namespace via Project->Add Reference.
Good Luck!
Paul Lyons, CCPL Certified Code Project Lurker What a long, strange trip it's been.
|
|
|
|
|
hey thanks paul... i got it i forgot to to declare span id. hope i said it right. later on i have included
|
|
|
|
|
Is it possible for a class to inherit from an interface and abstract class? For example:
interface iMyInterface
{
void Method1();
}
abstract class MyAbstract
{
------------some code
}
Can I have a class that will inherit from both iMinterface and MyAbstract?
Thanks.
|
|
|
|
|
*A C# class can inherit from only one base class, but can implement any # of interfaces.
*List the base class first, followed by any interfaces you want to implement.
class TheClass : MyAbstract, IMyInterface
{
}
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi
|
|
|
|
|
Hi All !
I have a main Form ( Form1 ) , and then create a new Form ( Form2 ). OK , now on Form1 I put Button0, Button11, Button12 and Edit1 . On Form2 : Button21, Button22 and Edit2 .
How to do if :
- When I click on Button0 ( Form1 ) then Form2 Appears . Typed something in Edit1 , and click on Button11 then all things in Edit1 will be copied to Edit2 ( on Form2 ) . If typed something in Edit2 and then Click on Button12 then Allthing in Edit2 will be copied to Edit1 . and the analogous process : if typed something in Edit2 and Click on Button21 then allthing in edit2 will be copied to Edit1 , if Click on Button22 then allthing in Edit1 will be copied to Edit2!
|
|
|
|
|
If you create second form you can access to its functions and memebers:
Form2 frm=new Form2();
To show this form use frm.Show()
If you want to call methods of first form you need to store reference to first form in member of second form.
class Form2 : Form {
Form1 frmRef;
}
Add this below code that creates second form: frm.refForm=this;
i'm only pointer to myself
|
|
|
|