.net

Dynamic SQL for updating a table from ASP .NET

I have an ASP.NET 3.5 application that I want to allow the user to select a table and allow CRUD operations on that table. The user will be restricted to a number of tables to edit however the tables and even database won't be known until after deployment; the web.config will setup the connection and tables. So I need to build a framewo...

Parsing strangely formatted files

I need to parse a file but the data is in a strange format that I'm not familar parsing. The data is always formatted like this. The field name is to the left and the data is right of the "=" and all fields are always in this order. File Data: Report 1 of 1 job_name = JOBNAME job_no = JOB99999 job_id = 6750 rprt_id = 27811 rprt_name ...

Possible to capture ComboBox "DroppingDown" event?

I have a System.Windows.Forms.ComboBox on a form and I want to capture the event just before the ComboBox's menu is displayed (something like "DroppingDown"). I can't seem to find a suitable event. Is capturing this type of event possible with a ComboBox? ...

Rounding issues with allocating dollar amounts across multiple people

What is the best way to solve this problem in code? The problem is that I have 2 dollar amounts (known as a pot), that need to be allocated to 3 people. Each person gets a specific amount that comes from both pots and the rates must be approximately the same. I keep coming across rounding issues where my allocations either add up to...

Is there a good way to detect empty results in a Linq-To-Entities query?

The only way I know of is awkward: 'check for empty return Dim count As Integer = (From s In myEntity.employee Where employeeID = myEmployeeIDVariable).Count 'If there is a record, then process If count > 0 Then Dim r = (From s In myEntity.employee Where employeeID = myEmployeeIDVariable).First() . . . do stuff . . . End If ...

System.UnauthorizedAccessException from Serial Port in VB.NET

I am using VB.NET 2008 Express Edition to access Serial Port which is a USB to Serial port. Since this is removable, the app user can disconnect it at any time in app. I am getting an unhandled exception when I remove the USB Serial Port. After research, it seems like a known problem in .NET (even in 3.5) I am looking for some solutio...

How to programatically tell if a word document is corrupt?

I've got a little C# application that interops with word converting a bunch of word .doc files into textfiles and for the most part this works fine. However, if the document is currupt then word cannot open the file and a dialog box pops up, which means that I cannot fully automate this conversion process - someone has to watch for the ...

Make C# assembly attribute show in details

Is there a way to make assembly attributes show up when you right click-> Properties->details on an exe? I know about the standard ones but I want to add my own (e.g. Email). Edit: Also if there is a way to do this post build, that would be fine. ...

Regular Expression for alphnumeric and space.

What is the regular exp for a text that can't contain any special characters except space? ...

Updating LinqDataSource from separate DataContext

I want to update one LinqDataSource with a record retrieved from a different DataContext. The problem is that the DataContext of the LinqDataSource doesn't seem to be made public so I can't get access to it to attach the new object to the DataSource's context. What is the normal way of doing this? Or should I just scrap the LinqDataSou...

Reason for Sorting a Hash Table

I was asked by an employer to sort a hash table. I always thought that the usage of a hash table was in a way non-sort friendly. Am I wrong in thinking this, and if not can you point me to a good VB.Net(Yes Kill me now, but it's an old system) method of sorting a hash table. Thanks. ...

Starting time of a process.

How do I retrieve the starting time of a process using c# code? I'd also like to know how to do it with the functionality built into Widows, if possible. ...

Persist an environment variables after app exits

Is it possible to persist an environment variable in a console application which is available after the process has exited. I want a console application to set a string which is available to the batch file which executed it. The console application is in dotnet. ...

How to write a self registering activex control (in C#)?

I've been able to create a small activex control, but it requires the dll to be registered on the client (using regasm). How can i avoid this registration problem? I'm attempting to write an activex control that is delivered over the web (to IE browsers) that will access the clients webcam (using directshow). Here's my simple control:...

populate a html list control using .NET

Hi I have a list defined like so: <ul id="myList" class='myClass'> <li class="myItemClass">Item 1</li> <li class="myItemClass">Item 2</li> </ul> using .NET how can I add items to the list dynamically? I also need to specify the class name on each new item ...

How to detect if another assembly is available to my application or not.

I have a command line winforms executable that calls into a Windows winforms application. Occassionally Ops forget to include the windows exe with the command line exe when deploying the application, leading to an error. How do I gracefully handle that and show a nice error instead of: Unhandled Exception: System.IO.FileNotFoundE...

Why events have no return types in .NET?

Events also 'does' something like methods, but they don't have return types and just voids? I am curious to know, Why is it so? and Why don't they return types? ...

What makes an app console or Windows Form application?

[Visual Studio 2008] I created a new project for console application and modified it to look like this: class Program { static void Main (string[] args) { Thread.Sleep (2000); } } Then I created another project for Windows Form application and modified it: static class Program { //[STAThread] commented this line...

System.DirectoryServices.AccountManagement in .net 2.0

Is there a: string name = System.DirectoryServices.AccountManagement.UserPrincipal.Current.DisplayName; equivalence in .net 2.0 framework? It uses the System.DirectoryServices.AccountManagement (ver 3.5) reference. I tried using that file on a .net 2.0 framework but to no avail. Basically, I want to retrieve the full username (f...

Adding json.net to project

Hi I have downloaded json.net. and added the dll file by clicking Add Reference. The dll file is now appearing in the bin folder. Now in the code I have tried calling the functions from Json.net Imports Newtonsoft.Json.JsonReader Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByV...