Introducing Crystal Reports
With the release of Visual Studio.NET 2003, Microsoft finally woke up to the needs of developers. They licensed Crystal Decisions to write a version of Crystal Reports to be the default reporting solution installed with .NET. Built into the IDE, Windows developers now have the tools to write presentation-quality interactive reports. More on : Introducing […]
PInvoke.net : Far beyond managed code (DllImport inside)
PInvoke.net is primarily a wiki, allowing developers to find, edit and add PInvoke* signatures, user-defined types, and any other information related to calling Win32 and other unmanaged APIs from managed code (written in languages such as C# or VB.NET). sample code : [DllImport(“aygshell.dll”)] static extern uint SHRecognizeGesture(ref SHRGINFO shrg); [StructLayout(LayoutKind.Sequential)] class SHRGINFO { public uint […]
[MSSQL] Reset Identity Column
If you are using an identity column on your SQL Server tables, you can set the next insert value to whatever value you want. An example is if you wanted to start numbering your ID column at 1000 instead of 1. It would be wise to first check what the current identify value is. We […]
Dynamic where clause using Linq To SQL
var query = from c in context.Customers select c; if (name != null) query = query.Where ( customer => customer.Name == name ); if (contactName != null) query = query.Where ( customer => customer.ContactName == contactName ); This way we can pass different combinations of arguments to the method and it will still build the […]
Linq to SQL Like Operator
Starting from a simple query from Northwind Database; var query = from c in ctx.Customers where c.City == “London” select c; The query that will be sent to the database will be: SELECT CustomerID, CompanyName, … FROM dbo.Customers WHERE City = [London] There are some ways to write a Linq query that results in using […]
Visual Studio DBML and SQL column default value
Usually when creating a database table, you will tend to add “default values” to some columns (Guid, Dates, …). BEGIN ALTER TABLE [dbo].[User] ADD DEFAULT (getdate()) FOR [Created] END Adding the table to a DBML file under visual studio will ‘by default’ disallow the default value in the table. The mapping with default values will […]
Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF.
This message is raised when you try to insert values in an identity column. Identity columns are auto incremented by the system and thus, does not allow manual modifications/insertions. To resolve this error, you have to set the Column_Identity ON by using the following syntax. SET IDENTITY_INSERT tblXYZ ON — your insert statement here SET […]
Winforms Textbox Autocomplete in c# using Linq
xyzDataContext dc = new xyzDataContext(); AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection(); var query = from c in dc.Clients select c.Company; foreach (String comp in query) { namesCollection.Add(comp); } tBoxCompany.AutoCompleteSource = AutoCompleteSource.CustomSource; tBoxCompany.AutoCompleteMode = AutoCompleteMode.SuggestAppend; tBoxCompany.AutoCompleteCustomSource = namesCollection; Result => AutoCompleteMode accept thoose values : External link : AutoComplete TextBox In WinForms AutoComplete TextBox in C#
DataGridView datasource : Use BindingSource or direct query ???
LINQ to SQL translates LINQ queries to SQL for execution on a database. The results are strongly typed IEnumerable. Because these objects are ordinary common language runtime (CLR) objects, ordinary object data binding can be used to display the results. On the other hand, sorting and change operations (inserts, updates, and deletes) require additional steps. […]
C# SFTP library
Libraries for accessing a SFTP server (FTP over SSH) using C# are not included in the framework ((not yet?)). Anyway, some snippets or libraries are available for free on the internet. I will list two of them : – SharpSSH SharpSSH is quite a good library, standalone, that implement the jsch library. – SFTP using […]