|
Great advice. I should use HashSet<T> more often...
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? 59.24% waren verstandig genoeg om NEEN te stemmen; bye bye viaduct.
|
|
|
|
|
Thanks
HashSet is great when you don't care about the order of elements it stores.
Best wishes,
Navaneeth
|
|
|
|
|
-Please keep in mind I am still a beginner programmer when adding replies. I need stuff explained in simple terms with some comments so I can understand it better. Thanks.-
For some reason I cannot seem to add items to various colums in my listview. I set all three columns up in the designer as well as the listview.
A little more info on what I am trying to achieve. I have this XML file:
<?xml version="1.0" encoding="utf-8">;
<List>;
<tem Name="One" Version="1.0" Filename="file.exe" />;
<Item Name="Two" Version="2.0" Filename="file2.exe" />;
</List>;
I have two queries as such:
var query_name = from n in ModListUser.Root.Descendants("Mod")
select n.Attribute("Name").Value;
var query_ver = from v in ModListUser.Root.Descendants("Mod")
select v.Attribute("Version").Value;
I need to line up the name and Version attributes into two different colums, but yet keep them lined up. So it would need to be like this:
Column1 | Column2 | Column3
One | 1.0 | file.exe
Two | 2.0 | file2.exe
For every item in the list which I don't know how many but eventually I am going to compare only selected values.
I realize I need a new Attribute for the file names that way I can match a directory and get only the needed items. Is there a way I can combine my query to get all the attributes for item with a specific name. Like being able to get 1.0 from One and so on?
So say if user only has Two but not One I would want to only display Two.
|
|
|
|
|
Here is adding the Item nodes into list view. You don't have to use LINQ. A simple XPath query should be enough.
XmlNodeList itemNodes = document.SelectNodes("/List/Item");
foreach (XmlNode node in itemNodes)
{
XmlAttribute nameAttribute = node.Attributes["Name"];
XmlAttribute versionAttribute = node.Attributes["Version"];
XmlAttribute filenameAttribute = node.Attributes["Filename"];
ListViewItem root = listViewObject.Items.Add(nameAttribute.Value);
root.SubItems.Add(versionAttribute.Value);
root.SubItems.Add(filenameAttribute.Value);
} You need to set the View property of listview to Details .
c#coder2009 wrote: Is there a way I can combine my query to get all the attributes for item with a specific name. Like being able to get 1.0 from One
Again a simple XPath query should do it.
XmlNode itemNode = document.SelectSingleNode("/List/Item[@Name='One']"); Look into the itemNode.Attributes collection.
Best wishes,
Navaneeth
|
|
|
|
|
XmlNodeList itemNodes = document.SelectNodes("/List/Item"); // assuming document is a XmlDocument instance.
Doesn't work. I get an error under document. I use XDocument not XmlDocument, should it be the same? Document should be the name of the XML object I load correct?
|
|
|
|
|
XDocument is for LINQ. I have used XmlDocument .
Best wishes,
Navaneeth
|
|
|
|
|
Thanks man, works great. Been waiting all day for a reply. Is there a way to check a directory for the file name and only display those that exist? Or do I need to display them all all the time? I knwo I am way overcomplicating this but once I figure this out I should be ok for the rest of my application. I think. Would you be able to put detailed comments in your code for me to understand better please?
I tried to add
if (File.Exists(PathVariable + Filename))
before the output but as soon as I do I get no output at all.
modified on Monday, October 19, 2009 1:31 AM
|
|
|
|
|
Yes. File.Exist() is the way to check the file existence. But I don't understand what issue you are facing here.
Best wishes,
Navaneeth
|
|
|
|
|
hi,
i am trying to use the borzoi 1.02 with Visual studio 2008 C# .NET,
i am trying to use the ECC implementation in this library,
so how can i integrate this library and use its functions from within VS 2008 C#.
thanks alot
|
|
|
|
|
What on earth are you talking about ? What makes you think we would know ? What is the library written in ? If it's not .NET, if it's a dll, you can use pinvoke to write a wrapper.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
If two client calls the same method, second client is waiting for the first client finished on WCF.
For example;
Client1 --CALL--WCF--> Metod_A
Client2 --CALL--WCF--> Metod_A
Metod_A spend 20 second for process. Client2 wait 20 second due to Client1.
I try, InstanceContextMode; PerSession, PerCall or Single. And I try ConcurrencyMode = ConcurrencyMode.Multiple but all of them give same result. Allways Client2 wait 20 second due to Client1.
How can I remove waiting time.
Note: Metod_A retrun value. So I can't use IsOneWay=true etc... And I don't want use thread.
Thanks...
modified on Sunday, October 18, 2009 5:46 PM
|
|
|
|
|
dataminers wrote: Metod_A spend 20 second for process
I strongly recommend you consider a redesign of your service. A service that takes 20 seconds to execute is far from scaleable as you've already seen with just 2 concurrent clients.
You should consider converting the service to one that requests that the operation be performed (in a separate thread) and returns quickly (after submitting the request). You'll also need APIs to check if the request has finished, and get the returned results (or error status).
/ravi
|
|
|
|
|
20 is just a example. Why second client wait due to first client when call same metod in WCF.
|
|
|
|
|
How are you starting your service host? Are you using a single instance of the service class or are you passing the service type to the ServiceHost constructor?
In the service code, there is some call to synchronization methods or some external API that could cause concurrent execution to block?
Edit: another possibility: are you executing SQL queries with transactions?
modified on Monday, October 19, 2009 6:37 AM
|
|
|
|
|
hi, I created a custom control and put textboxes in it.Even though I can use the events of textboxes, I can't use the events of the custom control itself. Any way to do it? Thanks
|
|
|
|
|
So long as you subscribe to the events properly and attach handler methods it should be no problem
using System;
using System.Drawing;
using System.Windows.Forms;
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
MyControl myControl = new MyControl();
Controls.Add(myControl);
myControl.BackColorChanged += new EventHandler(myControl_BackColorChanged);
myControl.BackColor = Color.Black;
}
void myControl_BackColorChanged(object sender, EventArgs e)
{
MessageBox.Show("Handler for myControl");
}
}
public class MyControl : UserControl
{
public MyControl()
{
BackColorChanged += new EventHandler(MyControl_BackColorChanged);
}
void MyControl_BackColorChanged(object sender, EventArgs e)
{
MessageBox.Show("Handler for own event");
}
}
|
|
|
|
|
Thanks for the code Dave but I think I couldn't explain well.Here is more detail;
I created a custom control and put a normal textbox in it and placed this custom control on a form. When the form is running, all I want is When I click on the textbox, I want to use the click event of the custom control,not the textbox.
thanks
Also, I use singleton for the form if that differs
|
|
|
|
|
When you click in that textbox, only the textbox's Click event is going to fire. You didn't click on the surface of the custom control so its Click event won't fire. In order for the Form to see the TextBox's Click event, you're going to have to handle the Click event in your custom control and, in that event handler, Raise your custom controls Click event.
|
|
|
|
|
|
I have an application that is (should) save blobs in the database. It saves all the columns except the blob. I have been trying everything I can think of. If anyone has something to try, please let me know. I keep telling myself this should not be hard. Thanks in advance.
Here is the table (SQL Server 2005).
CREATE TABLE [dbo].[publication] (
[id] INT IDENTITY(1,1) NOT NULL,
[title] VARCHAR(50),
[category] VARCHAR(50) NULL,
[orig_file_name] VARCHAR(255) NULL,
[publish_date] DATETIME NOT NULL DEFAULT(GETDATE()),
[data] IMAGE NOT NULL,
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
Here is the code.
public static int uploadPublication(string title, string originalFileName, DateTime publishDate, string category, System.IO.Stream publication)
{
byte[] publicationData = new byte[publication.Length];
publication.Read(publicationData, 0, Convert.ToInt32(publication.Length));
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ClubSiteDB"].ConnectionString);
SqlCommand command = new SqlCommand("INSERT INTO publication (title, orig_file_name, publish_date, data, category) VALUES ( @title, @orig_file_name, @publish_date, @data, @category); select SCOPE_IDENTITY()", connection);
SqlParameter param0 = new SqlParameter("@category", System.Data.SqlDbType.VarChar, 50);
param0.Value = category;
command.Parameters.Add(param0);
SqlParameter param1 = new SqlParameter("@title", System.Data.SqlDbType.VarChar, 50);
param1.Value = title;
command.Parameters.Add(param1);
SqlParameter param2 = new SqlParameter("@orig_file_name", System.Data.SqlDbType.VarChar, 255);
param2.Value = originalFileName;
command.Parameters.Add(param2);
SqlParameter param3 = new SqlParameter("@publish_date", System.Data.SqlDbType.DateTime);
param3.Value = publishDate;
command.Parameters.Add(param3);
SqlParameter param4 = new SqlParameter("@data", System.Data.SqlDbType.Image);
param4.ParameterName = "data" ;
param4.Value = publicationData;
command.Parameters.Add(param4);
connection.Open();
object result = command.ExecuteScalar();
connection.Close();
if (result != null)
{
return Convert.ToInt32(result);
}
else
{
return 0;
}
}
|
|
|
|
|
|
Thank you very much for the link. The my code is almost line-for-line the same as the example article. Still does not help my problem.
|
|
|
|
|
Then take a closer look. The difference is, mine works, yours doesn't.
only two letters away from being an asset
|
|
|
|
|
Hello all,
Where is what I have done:
1. I have a database(MySQL) with one table.
2. I have my data source made in visual studio(2008)
3. I drop the table unto my form.
So right now I am able to move between records and can add/deleted/update records using the buttons on the binding Navigator control.
But when I add a button to the form to move between records nothing happens. Here is the code I did for the button
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
<br />
this.BindingContext[this.empDataSet, "employees"].Position++;<br />
<br />
<br />
}<br />
Is there a way that I can use both the Navigator control, and use my own buttons at the same time?
|
|
|
|
|
I am not sure, but I think
this.BindingContext[this.empDataSet, "employees"].Position++;
is just a result. You must be initialize this result to navigator control related property.
Best Regards...
|
|
|
|