|
You should set the Tag property while you are creating the nodes, not in a process after the nodes are created. The tag property should have, at minimum, some way for you to find the database row that needs to be updated.
One simple way of doing this is to:
* Retrieve your data.
* Construct the tree nodes, setting the Tag to that row's ID.
* When the user clicks a node, call the database, setting the appropriate value for the row which is identified by the Tag.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
I am using a three state check box. When a user clicks on a node, I recursively set the CheckState property of the children nodes and parent nodes appropriately. My second option (pressing the save button and committing changes to the DB once) is more suited here as that will take only one round trip call to the database.
John, could you demonstrate by some example how one would update the local data table and the CheckState value in the nodes?
In order in order to successfully record all the changes in the nodes to the data table, I'll loop through all the nodes and copy the CheckState value to the data table. Basically, I have to traverse the entire tree, starting with the root. Is that how you are envisioning?
BTW, I am setting the tag property as I am constructing the nodes, as you suggested.
Help appreciated.
Thanks again
|
|
|
|
|
The save button sounds workable.
That's good that you're already storing the information about which database row corresponds to the TreeNode. Without it, you would have a very hard time doing this.
An example? That's a very tall order, since I don't know anything about the code you are using (data access, type of database, etc.). So, some pseudo-C# code is probably the best I can do.
<br />
private void SaveButton_Clicked(object sender, EventArgs e)<br />
{<br />
SomethingOrOther data = new SomethingOrOther();<br />
<br />
foreach (TreeNode node in yourTree.Nodes)<br />
{<br />
YourClassInfo info = node as YourClassInfo;<br />
data.QueueUpdate(info.Row, node.Checked);<br />
}<br />
<br />
data.Save();<br />
}<br />
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
I basically just want to send a 2 part message. Part 1: text, Part 2: Html.
Any ideas on how I'm going to get this into my .NET application?
|
|
|
|
|
http://www.quiksoftcorp.com/freesmtp/
in case anyone wants to know
|
|
|
|
|
Hi All,
I have created a database in SQL and setup relationships the works. What happens is, when you enter info from a website, numeric values gets written to SQL.
What I need is to display the data behind the values in a datagrid. I have created a stored procedure to inner join the needed data but how do I execute the stored procedure to display the data in a datagrid?
Thanks!
Illegal Operation
WannaBe and GonnaBe Systems Developer
|
|
|
|
|
You will want to look at the System.Data and System.Data.SqlClient namespaces.
One way to do what you're attempting would be to create a System.Data.SqlClient.SqlConnection object using a valid connection string for your database, then create a System.Data.SqlClient.SqlCommand using the connection with the name of your stored procedure as the CommandText , and StoredProcedure as the CommandType . Finally, create a System.Data.SqlClient.SqlDataAdapter object based on the SqlCommand object (there is a constructor that accepts a SqlCommand instance).
Once the DataAdapter was created, you could declare a System.Data.DataTable and call the SqlDataAdapter's Fill method to retrieve your data into the DataTable . After the data is retrieved and stored in memory in your DataTable , you can set your DataGrid 's DataSource property to be the DataTable (or you can further use a System.Data.DataView of the DataTable if you want to sort your results), and call the DataGrid 's DataBind method. The DataGrid should then display your results.
There's quite a lot more that can be done with configuring the DataGrid , but these are the basics. There are also several different ways you could get the data you're after using a variety of combinations of types in the System.Data namespace and its sub-namespaces, but this is fairly straightforward.
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 there
In the MSDN i read that the Timeout property from the WebRequest class isn't available when using the asynchronus way. When i try to webrequest a uri which doesnt exists, the program hangs a couple of seconds before throwing an exception. If the main part of the uri exists but e.g. the path is incorrect, then ill get an error response right after.
How to reduce the hang/timeout when webrequesting an uri which doesn't exist? Any ideas?
--------------------
Thanks for reading
|
|
|
|
|
i just created a NT service project with the help of Service Project Template given in VS,and installed it by using installutil servicename.exe
however its not appearing in Service Panels,here are contents i see on console window
Beginning the Install phase of the installation.
See the contents of the log file for the c:\windowsservice1\windowsservice1\bin\
debug\windowsservice1.exe assembly's progress.
The file is located at c:\windowsservice1\windowsservice1\bin\debug\windowsservi
ce1.InstallLog.
Installing assembly 'c:\windowsservice1\windowsservice1\bin\debug\windowsservice
1.exe'.
Affected parameters are:
assemblypath = c:\windowsservice1\windowsservice1\bin\debug\windowsservice1.e
xe
logfile = c:\windowsservice1\windowsservice1\bin\debug\windowsservice1.Instal
lLog
No public installers with the RunInstallerAttribute.Yes attribute could be found
in the c:\windowsservice1\windowsservice1\bin\debug\windowsservice1.exe assembl
y.
The Install phase completed successfully, and the Commit phase is beginning.
See the contents of the log file for the c:\windowsservice1\windowsservice1\bin\
debug\windowsservice1.exe assembly's progress.
The file is located at c:\windowsservice1\windowsservice1\bin\debug\windowsservi
ce1.InstallLog.
Committing assembly 'c:\windowsservice1\windowsservice1\bin\debug\windowsservice
1.exe'.
Affected parameters are:
assemblypath = c:\windowsservice1\windowsservice1\bin\debug\windowsservice1.e
xe
logfile = c:\windowsservice1\windowsservice1\bin\debug\windowsservice1.Instal
lLog
No public installers with the RunInstallerAttribute.Yes attribute could be found
in the c:\windowsservice1\windowsservice1\bin\debug\windowsservice1.exe assembl
y.
Remove InstallState file because there are no installers.
The Commit phase completed successfully.
any help?because i dont think there is some mistake in code or calling methods
Thanks
MyBlogs
http://weblogs.com.pk/kadnan
|
|
|
|
|
Hi,
The key portion of the error message is this:
<br />
No public installers with the RunInstallerAttribute.Yes attribute could be found in the c:\windowsservice1\windowsservice1\bin\debug\windowsservice1.exe assembly.
This means that you don't have a ServiceInstaller with the [RunInstaller] attribute set to yes. Check your code to see if that is missing completely, or if it's just needs a little tweak. (And look up ServiceInstaller in the docs if you haven't already.)
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
I have dataset which is binded to datagrid and dateformating is done based on culture. This happens fine with out any problem.
If my dataset is retrieved as a xml string using dataset.GetXML then converted to dataset and binded to datagrid. The date formatting wont take place instead it displays in the following format
2005-02-09T14:13:24.8280000-00:00.
But I want the dateformatting to take place on datagrid in either of the case.
Padvit
|
|
|
|
|
Hi, i want to open a word document in an existing class including the below code.
.........
.........
object fileName = strFileName;
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
oDoc = oWordApplic.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 isVisible,ref missing,ref missing,ref missing, ref missing);
oDoc.Activate();
It works fine in my computer which includes Office 2003, but if I try to run this code in another computer which includes Office 2002 it gives the following error:
Error-->"System.Exception: object reference not set to an instance of an object.
this error occurs in the line of oDoc = oWordApplic.Documents.Open(..) .
Can anybody help me please.
Fatih Sen
|
|
|
|
|
Hi!
The type libraries for different Word versions are not compatible.
You should program against the lowest version number, i.e. get yourself a primary interop assembly of Word97 and use only the objects defined there.
That way your program should work with Word97 and up.
If you really need objects/functionality from later Word versions, then you will have to pick the prim. interop assembly for this version, but your program will not work with a lower Word version.
Regards,
mav
|
|
|
|
|
I used Microsoft Office 11.0 Object Library. So, should I use lower version like Mic. Off. 10.0 Library. Do you mean that?
Fatih Sen
|
|
|
|
|
|
Hi again mav.
I changed the Microsoft.Office 11.0 Object Library with Microsoft.Office 10.0 Object Library. And now it gives the following error:
System.Exception:System.Runtime.InteropServices.COMException. There is insufficient memory.Save the document now at Microsoft.Office.Interop.Word.Documents.Open(....)
Do you know why this situation occurs now?
Fatih Sen
|
|
|
|
|
Now it works. After changing from Microsoft.Office 11.0 Object Library with Microsoft.Office 10.0 Object Library I got the above error. Then,start>run>dcomcng. Clicking the Microsoft Word Document , in the Identity I changed the user to "interactive user".
Thanks mav.
Fatih Sen
|
|
|
|
|
I have a report ex:
ReportDocument report=new ReportDocument();
report.Load("path to the report);
DataSet dataSet=new DataSet();
I have a connection to a database SqlConnection...,
SqlDataAdapter adapter=new SqlDataAdapter("Select * From database Where x='y'",connection);
adapter.Fill(dataSet);
report.SetDataSource(dataSet);
crystalReportViewer.ReportSource=report;
and when I run the report not returns the date what I said in sql,he return all the rows from table.
Please help me.
|
|
|
|
|
Did you save your data with "Save Data With Report"?
Is the query valid? Check what the query returns. Hope this will help.
<italic>Work hard, Work effectively.
|
|
|
|
|
Yes the query is valid,I verify the dataSet and he has the dates what I want,but I didn't save data with "Save Data With Report".
|
|
|
|
|
Hi guys!
I have written a set of functions that interacts with a modem. The functions works fine when I call them from a ordinary machinecode compiled c program. Now to the problem. Just for fun, I have put my functions in a dll and intend to call them from a c# app.
I have successfully called unmanaged functions that takes null terminated strings (char*) as parameters from my c# app. I used Marshal.StringToHGlobalAnsi that returns a IntPtr for that.
To call unmanaged functions that returns null terminated strings I have read that I should use pointers i an unsafe context. My test function returns char* and I call the function from code that is marked unsafe.
The function call i the c# app
<br />
unsafe public String callUnsafe()<br />
{<br />
char* resp = do_READ_FROM_OPENTCPSOCKET(comdev);<br />
return new String(resp);<br />
}<br />
The function prototype i the c# app
<br />
[DllImport("dll.dll", CharSet=CharSet.Unicode)]<br />
private static extern char* do_READ_FROM_OPENTCPSOCKET(Int32 comdev);<br />
The function prototype in the unmanaged dll
<br />
extern "C" { <br />
char* DLLDIR do_READ_FROM_OPENTCPSOCKET(HANDLE comdev);<br />
}<br />
The code compiles fine, but when I run it all I get is a EntryPointNotFoundException.
Has anyone tried this before?
Maybe someone has some codesnippets that they can share.
thanks in advance!
/Mike
|
|
|
|
|
Have you tried it the simple way, yet? The CLR provides marshalling capabilities for you, so you don't have to worry about calls to Marshal.StringToHGlobalAnsi() when things are set up well.
<br />
[DllImport("dll.dll", CharSet=CharSet.Ascii)]<br />
private static extern string do_READ_FROM_OPENTCPSOCKET(Int32 comdev);<br />
<br />
Give this a shot, and forget about using "unsafe" when you try it. For additionaly help in the interop area, try watching this[^].
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Thx, I will give it a try!
|
|
|
|
|
For some odd reason I still get a EntryPointNotFoundException when I try to invoke an unmanaged function that returns char*. Could it be something dodgy with my unmanaged dll?
|
|
|
|
|
I am attempting to write a C++ DLL function that will return a string and then call that function from C#. Looks like you have working code that does this or something very similar. Could you show what you did to make this work?
Here is the relevant portion of my code:
In C++ DLL header (.h)
extern "C" __declspec(dllexport) int addfive(int x);
extern "C" __declspec(dllexport) char* putFolderList();
In C++ DLL source (.cpp)
int addfive(int i) { return i+5 ;}
char* putFolderList(){ return "my string" ;}
In C#:
using System.Runtime.InteropServices;
[DllImport("DLLBuildTest.dll")]
static extern int addfive(int x); // VALID
static extern char* putFolderList(); // NOT Valid
Paul
|
|
|
|