.net-3.5

Listview ItemSelectionChanged fires twice?

I have a Winforms App in C# with a ListView control. This ListView shows a list of TO-DO items and I am using the 'ItemSelectionChanged' event to handle updates. The problem is that the 'ItemSelectionChanged' event fires twice each time I try to make an update. The ItemSelectionChanged event refreshs the form to represent the update...

check against: null vs default()?

I want to check if a reference type is null. I see two options (_settings is of reference type FooType): if (_settings == default(FooType)) { ... } and if (_settings == null) { ... } How do these two perform differently? ...

Error: The key-value pairs that define an EntityKey cannot be null or empty. Parameter name: record

I'm trying to update a record using the Entity model (3.5) when I get this error. I have no such parameter named "record". In walking through the code, a single entity is found, The four Entity keys are filled correctly("EntitySet=WOTimeRecording;WorkOrderNbr=69229;UserQID=Qlab64;WeekIdentifier=2010-Week14;TimeIdentifier=5") , and the ...

Getting the ListView ItemCheck to stop!

Following some SO advice I have tried the following on the ItemCheck event of a ListView control: private void lstTasks_ItemCheck(object sender, ItemCheckEventArgs e) { ...some code return; } The idea being that that return; will cancel the event ...but does running some code before the blank return; negate the de...

LINQ 2 SQL with WCF and serializing EntityRef

Hi all, I have a LINQ 2 SQL project and I'm trying to use it in WCF. EntitySets serialize perfectly if I specify them with the LoadWith dataloadoptions. The problem is EntityRefs. I have a customer with 1 address. But 1 address can have multiple customers. How do I make sure that the Customer is passed over the line WITH the Addres...

ComboBox SelectedIndexChanged event: how to get the previously selected index?

I have a user control which has a ComboBox and a SelectedIndexChanged event handler. In the event handler, I need to be able to tell what was the previously selected index... can anyone point me in the right direction? private void cboTargetMode_SelectedIndexChanged(object sender, EventArgs e) { // need to get the previously select...

Format Removable media with c# programming

I want to format (FAT32) removable drive with c# programming. In the internet I found a way, but the problem is that it opens the generic windows format program. But I want to do it with C# only and no built in windows support. My method is: // FAT32 Format Button click event [DllImport("shell32.dll")] static extern uint SHFormatDrive(...

PrinterSettings.InstalledPrinters - Which computer is it referring to?

Hey Everyone, If I'm calling PrinterSettings.InstalledPrinters in my web application; is that referring to the printers on the computer that the site is being hosted on, or the printers on the computer of the user that's accessing the application? ...

Bulk Insert or Another way to load a lot of data at once using C# and SQL server?

I have an application where a user can upload files and associate the files with a project. The projects can be duplicated. Here is an example of an object: Public class Project{ Int ProjectId{get; set;} string ProjectName{get;set;} List<int> FileIds{get;set} } When I go to duplicate the project, say, what is the best way ...

Deploy multiple configs or put everything in a single web config?

Our solution file contains many different projects including an ASP.NET MVC web app, a windows service, and several desktop applications. One project handles logging and has an app.config file containing a list of recipients to inform when something fatal has been logged. Concerning the deployment of our webapp, I was wondering if it...

Reusing SqlConnection within a DAL method

Suppose we have a DAL method public void BuyProduct(int productId, int quantity, int buyerId); Within that method we need to call 2 stored procedures: EXEC tblOrders_CreateNewOrder EXEC tblProducts_RecalculateStock Is it a good practice to create 2 SqlCommands - one per stored procedure and to use a single SqlConnection to execute...

How to use collection with entity framework 3.5 in n-tier application?

I'm starting new project with EF 3.5 (Visual Studio 2008 SP1, .NET Framework 3.5 SP1) It's N-Tier application, one important aspect of this project is return collection of datums which I prefer to use IEnumerable. I also use EntityBag in this project and I found some problem. I can return collection from AppServer but I can't track any...

How to remove the non client area of a WPF window without using AllowTransparency

I would like to remove the resizing border from my WPF custom window. I already found that I have to handle the WM_NCCALCSIZE message and return 0. That removes the border and aligns the window to the top left corner of the window. The problem is that by doing so, the client area increases and the WPF root control doesn't. That creates b...

Time out exception in 1st run for local DB

My connection string is like the following. It shows 'Timeout Exception' first time I run the application. But, for the subsequent run, it's ok. I think, it might take some time to attach the DB to the SQLExpress Server. Is there anyway to increase Timeout period? Thanks I am using SQLServer 2005 Express and VS 2008 and .Net 3.5. ...

Trying to load a DataSet, but it is always null. Regular sqlReader.GetValue() is not

I don't use DataSets much. Usually find myself using an ORM or just a basic sqlReader.Read() followed by some GetValues(). I'm working on some legacy code that has DataSets all over the place, and while fixing a bug was trying to DRY some of it up. However, I can't seem to actually get the data loaded into a non-typed DataSet. publ...

asp.net validation control for only TEXT input

What validation control would I need if I want the user to enter only TEXT characters in a textbox and what would be the validation expression? ...

Using XML as a SQL Parameter to load multiple objects

Hey everyone, I'm a newbie at this, so bear with me for a second. I have a dictionary like so: var dict = new Dictionary<int, SalesStatistics>(); SalesStatistics is a custom class; that contains various information about products. The key field holds the ProductId. I need to iterate across this dictionary, and for each ProductId i...

How to create an object with constructor arguments in an AppDomain? (.NET 3.5)

I am trying to create an instance of an object inside of an AppDomain. With the below code, I get an Exception "Type is not resolved for member" Here is the code: private T GetInstance<T>(AppDomain domain, params object[] constructorArguments) { string assemblyName = Assembly.GetAssembly(typeof (T)).FullName; string typeName =...

An api to get actual time for asp.net

My server clock is running slow for some reason. I need to put a timestamp on my database transactions and need a reliable time source. Is there an api to the world time zone site or something similar? ...

Using expression tree to navigate and return an object that owns a property

Hi, Given an expression that points to a property in an object graph, I want to retrieve the instance that owns the property withing that graph. I've been struggling. The current code just gives me System.InvalidOperationException : Lambda Parameter not in scope [Test] public void TestExpression() { var person = n...