Removal with LINQ to SQL in Visual Studio

I'm using LINQ to SQL in visual studio to interact with my database. Now I added methods that add, change etc to my code, but I cant make removing a row work. here is my remove method: public bool removeUser(User toBeRemoved) { try { theDBDataContext

Double qualified not displayed correctly

I'm trying to make some controls which size would be set using qualified double so that the control size are the same no matter which screen it's displayed on. So I have this converter which converts double to qualified double: double effectiveValue

NUnit Test for ActionResult that checks user roles

I am currently new to ASPNET MVC framework and I wanted to do some unit testing using NUnit, and I am having difficulties. My issue is that I have a controller and most of the ActionResults methods have got checks inside them checking whether the cur

Where is the SqlException constructor?

I am writing unit test to verify detection of exception caused by database overload. But I cannot find constructor of SqlException. Why I cannot see constructor in metadata? Following code is just to help understand why I am looking for constructor.

Quickly remove unprocessed exceptions in TPL

My problem: I want to use TPL in WinForms application under .NET 4 and I need the task continuations to elevate any unhandled exceptions immediately ("fast throw") instead of waiting for GC collecting the Task. Is it possible? In .NET 4.5 with a

Control articles in article control

(After pulling hair for 8 consecutive hours, I've given up. Will be very thankful if someone could come to rescue): Here's what I have: AlbumItem: This is an ItemsControl that uses a Canvas as its ItemsPanel and binds to a colletion property of the u

Get DataGrid Rank by Index

I am trying to obtain DataGridRow from my DataGrid based on index. I am using following code: public DataGridRow GetGridRow(int index) { DataGridRow row = (DataGridRow)DG_Statement.ItemContainerGenerator.ContainerFromIndex(index); if (row == null) {

The RegEx force quantifier is valid

I am struggling to get my regex validation for name initials to work. I have the following code: // S.P. of Sp.A. string voorletters = "S.P.aAa"; // This should be invalid string regexPattern = "^([A-Z]{1}[.]|[A-Z]{1}[a-z]{1,}[.])*"; v

C # HTMLElementCollection Launches InvalidCastException

EDIT: part of this question is already answered elsewhere, but I feel this thread provides some more information and might be handy to know Title pretty much says it all but here is some more information: I have a function that uses the HTMLdocument

Consultation not to return anything

I have 2 tables: winery and wineType (in wineType I have foreign key for winery, called wineryID). I try get all winery names that produce wine like the one the client selected from drop down list. And I have this function public void ispolniLista()

Obtain a control property of another thread

I want to get a control's property from a BackgroundWorker in my form: foreach (ListViewItem i in ListView.CheckedItems) { //error: Cross-thread operation not valid: Control 'ListView' accessed from a thread other than the thread it was created on. /

Check that any directory exists inside given

My application is Windows, C# 3.0. I want to make sure that a directory given does not contains subdirectories. Naive code like if (Directory.GetDirectories(path).Length != 0) will work very slow on directories which contain e.g. 10000 subdirectories

LINQ - View about 6000 unique records by the WHERE clause

I've got a problem and no idea how to solve it. Imagine you have a List<int> with about 6000 unique id's that matches the id's of a table with about a million records in a sql datatable. I want to select those 6000 records that matches those id's vi

conflict resolution in the distributed list

I would like to maintain a list of objects that is distributed between N load balanced servers: whenever a client changes the list on one server, I would like these changes to migrate to the other servers. So, I guess this is a case of master-master

change frame error c #

I am running Visual Studio 2010. I just change the frame work of my project from 4.0 to 3.5. I removed the reference Microsoft.Framework that it asked me to remove then tried to compile. I now get the error: Error 1 Could not load file or assembly 'S

by holding the value of a variable in c # .net winforms

i have a Form which has a button, on the button click event, a variable locklogin is increased by 1 when locklogin =3 , then the form button gets disabled and the form needs to be closed. on closing the form , locklogin loses its value. but i want to

How do I create a method signature caching?

I'm building an app in .NET and C#, and I'd like to cache some of the results by using attributes/annotations instead of explicit code in the method. I'd like a method signature that looks a bit like this: [Cache, timeToLive=60] String getName(string

Identify whether a user is in the local administrators group

My Problem I'm using PInvoked Windows API functions to verify if a user is part of the local administrators group. I'm utilizing GetCurrentProcess, OpenProcessToken, GetTokenInformationand LookupAccountSid to verify if the user is a local admin. GetT

Powershell / GetEnumerator

I have a simple question: Why the program below does not write the whole array $lines? It is looping forever. I am really confused.. function Get-Current ($enumerator) { $line = $enumerator.Current return $line } $lines = @('a', 'b', 'c') $enumerator

Deployment .NET COM DLL, Error (0x80070002)

I have a .NET COM assembly I am attempting to deploy to a web server (IIS 6 Win 2003). We have successfully deployed this assembly to our test environment, but the production environment is not working. The assembly is being called from a classic ASP

Converting an int to an array of BCD bytes

I want to convert an int to a byte[2] array using BCD. The int in question will come from DateTime representing the Year and must be converted to two bytes. Is there any pre-made function that does this or can you give me a simple way of doing this?

How does a value type actually work in .net?

Somewhat academic question, but: How do value types like Int actually work? I've used Reflector on mscorlib to find out how System.Int32 is implemented, and it's just a Struct that inherits from System.ValueType. I was looking for something among the

Why does .NET XML API not protect me from the null character?

My application receive strings from outside and construct an XML document string fromOutside = "\0"; XAttribute a = new XAttribute(fromOutside); when the attribute value contains null character then I got exception when trying to save XML to the

Why List & lt; T & gt; not secure?

From the following site: http://crfdesign.net/programming/top-10-differences-between-java-and-c Unfortunately, List<> is not thread-safe (C#'s ArrayList and Java's Vector are thread-safe). C# also has a Hashtable; the generic version is: What makes

Disable the output button on a Windows Form?

Is there a way to disable the exit button on a windows form without having to import the some external .dll's? I disable the exit button by importing dll's using the following code but I don't like it. Is there a simpler (built-in) way? public Form1(

How to format an HTML string by program

I've got unformatted html in a string. I am trying to format it nicely and output the formatted html back into a string. I've been trying to use The System.Web.UI.HtmlTextWriter to no avail: System.IO.StringWriter wString = new System.IO.StringWriter

Wait for the file to be unlocked in .NET

What's the simplest way of blocking a thread until a file has been unlocked and is accessible for reading and renaming? For example, is there a WaitOnFile() somewhere in the .NET Framework? I have a service that uses a FileSystemWatcher to look for f