November 26th, 2011
ndoc3 (link) is a great tool to quickly generate documentation pages from .net assemblies. The download attached to this document is the current version rebuild against the .net 4 platform, so it is capable of processing .net4 assemblies.
Download binary
NDoc 3 for NET4 assemblies
Posted in (re-)Builds | Tags: (re-)Builds | No Comments »
October 16th, 2011
Today’s writeup is was triggered by a question from a reader. While its something that probaly everyone archieved at some point using the standard Microsoft grid control, the sheer amount of features avaiable on the Devexpress DXGrid make things sometimes less obvious for those starting out with the the suite.
So here is a complete working sample, that does the following:
- Read the starter data from a table, and present it in a grid control
- Allow edits to only one column
- We want to highlight the editable column with a color to draw the user’s attention to it.
- We want the pricing and line total column to use a currency layout
- We want the pricing and line total column to be right aligned
- Perform a calculation everytime an edit has been made
Read the rest of this entry »
Posted in DevExpress | No Comments »
June 12th, 2011
These samples will show the basic handling of the treelist control, to create a structure and react to clicks by the user. Used in this example is the treelist control from the DevExpress suit, but you can apply the same technique to basicaly any treelist control with minimal changes.
The first example shows how to manualy build a tree from code, and then react to clicks. The second example archives the exact same tree, but retrieves it’s data from a simple sql server table, making the content of the tree list much more dynamic. Read the rest of this entry »
Posted in DevExpress | 15 Comments »
May 17th, 2011
UPDATE a field from a different table
This snippet retrieves the value from table2.field2, and places it in table1.field1.
update table1 set table1.field1 = table2.field2
from table1,table2
where table1.key = table2.key
UPDATE a field with a SUM from a different table
This snippet adds up multiple entry’s in the second table which have the correct key, and places the sum in the first table. This technique is usefull for totaling seperate lines in table2 into a different table.
update table1 set field1 = ( select sum(table2.field2) from table2 where table1.key = table2.key)
Posted in SQL | No Comments »
May 16th, 2011
This sample shows how to enumerate and select a specific tray to use for printing.
The code works bij intercepting the oReport.PrintingSystem.StartPrint event, by adding a handler and sending it to a routine which enumerates the trays of the printer.
Read the rest of this entry »
Posted in DevExpress, VB.NET | No Comments »
May 6th, 2011
When writing long query’s or stored procedures using temporary tables, you may run into an error like:
Cannot resolve the collation conflict between “Latin1_General_CI_AS” and “SQL_Latin1_General_CP1_CI_AS” in the equal to operation.
The cause of this error is that the tables you are querying against have a different collation then the server default. This causes the temporary tables in TempDb.. to have a different collation too.
To specify the collation your database has during the creation of your temptable, implemenet it like this:
-- Clear out temp. table if it already exists
begin try
drop table #sometable
end try
begin catch
end catch
-- Create with enforced collation
create table #sometable (
field1 nvarchar(50) collate Latin1_General_CI_AS,
field2 nvarchar(50) collate Latin1_General_CI_AS,
.....
)
Posted in SQL | No Comments »
April 20th, 2011
DevExpress – Coloring individual cells or rows in a Gridcontrol based on a cell value. This sample hooks into the RowCellStyle event of the Gridview, and evaluates the value of the cell. Depending on the outcome, a background color is assigned to the cell. Read the rest of this entry »
Posted in DevExpress | 1 Comment »
April 1st, 2011
From: http://social.technet.microsoft.com/Forums/en-US/w7itproSP/thread/0d763f12-30f8-4d13-8534-315d5c34dd0d
Problem: The Windows 7 RSAT package is made for the Windows 7 RTM version and does not install on Windows 7 SP1
Solution: Manualy extract and install the package, bypassing the version check
expand -f:*.* amd*
pkgmgr /n:.Windows6.1-KB958830-x64.xml
While no output is send to the screen, this does install in the background. After a few minutes the RSAT options are added to the add/remove functions section.
Posted in Overflow | No Comments »
March 15th, 2011
With the release of Windows 7 SP1 a hotfix has been included that makes it possible to once again catch user mode exceptions on 64 bit development machines. (see the excelent writup “the case of the disappearing onload exception” here for details and an explanation of what is exactly going on.
To disable the filtering on Windows 7 SP1 development machines add the following registry key:
- Locate the registry subkey: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
- Create a registry entry of the DWORD32 type named “DisableUserModeCallbackFilter”
- Set the value of the DisableUserModeCallbackFilter registry entry to 1
Posted in Overflow | No Comments »
March 14th, 2011
I once made the mistake to solve the wish to have an image column in a datagridview by adding a VARBINARY field to the underlying database, and binding that column to the datagridview. Although the technique worked in the sense that it actualy does show the image that is now present in each and every row in your table, it’s needless to say that the performance and storage waste hit is horrible on large tables.
In this article i provide two better ways to add an image to a datagridview. The first code sample does this by manupilating the datagridview after the base data has been bound to it. The second code sample modifies the datatable *before* it is bound to the gridview, and then provides the data from the database server and the localy added image data to the datagridview. Read the rest of this entry »
Posted in C# | No Comments »
February 11th, 2011
DevExpress
' --- Apply currency format
GridView7.Columns("price").DisplayFormat.FormatString = "c"
GridView7.Columns("price").DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
' //
' --- Right align a column
GridViewArtikelInslag.Columns("datum").AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far
' //
' --- Auto fit sizes to content
GridView7.OptionsView.ColumnAutoWidth = False
GridView7.BestFitColumns()
' //
Default .NET Control
' --- Activate auto sizing
DataGridViewA.AutoSizeColumnsMode = DataGridViewAutoSizeColumnMode.Fill
' //
'--- Apply currency format
DataGridViewA.Columns("price").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
' //
' --- Set fill weight
DataGridViewA.Columns("price").FillWeight = 300
' //
Posted in DevExpress, VB.NET | No Comments »
January 30th, 2011
During installation of especialy server core versions such as HYPER-V 2008 it can be cumbersome to reach the machine with the default secure settings. Below are the commands to disable and re-enable the firewall from the command line
To disable the firewall in the currently running profile, you can issue the command:
netsh advfirewall set currentprofile state off
And re-enable with:
netsh advfirewall set currentprofile state on
One the machine is up and running you can use the RSAT mmc snap in’s to manage in more detail.
Posted in Overflow | No Comments »
January 18th, 2011
By default the DevExpress grid control will force all columsn to fit in the default view. These property’s can be used to change that behaviour and have teh columns size to the content of the cells and a scrollbar to appear.
' --- A blank grid control is present on the form, which will supply the
' gridview1 object by default.
' --- By default, ALL columns will be forced into the avaiable width
GridView1.OptionsView.ColumnAutoWidth = False
' --- Size the columns to the content
GridView1.BestFitColumns()
The following code snippet applies the technique to a form which contains a gridcontrol with no bindinge made at design time. At runtime, a qeury is run against an ODBC database, and the result of that query is visualized in the grid.
Code to run the query and bind the results to the grid:
Private Sub RunQuery()
Using oCon As New OdbcConnection(My.Settings.ODBCLink)
oCon.Open()
Dim sQuery As String = TextEdit1.Text
Using oDa As New OdbcDataAdapter(sQuery, oCon)
Using oDs As New DataSet
oDa.Fill(oDs, "resultset")
GridControl1.DataSource = oDs
GridControl1.DataMember = "resultset"
End Using
End Using
End Using
End Sub
And apply the formatting so we can see all resulting data
GridView1.OptionsView.ColumnAutoWidth = False
GridView1.BestFitColumns()
Posted in DevExpress, VB.NET | Comments Off
January 14th, 2011
These samples show handling the clipboard in the most basic way. First a test is done to see if there currently is text on the clipboard. If a text is found, the programm proceeds to read and display the text, and then replace it with a new text.
By modifieing the parameters you can use the same technique to handle other formats such as images or audio and video fragments.
VB.NET Implemtation
Imports System.Windows.forms
Module Module1
Sub Main()
If Clipboard.ContainsText = True Then
' --- Get the current text from the clipboard
Dim sClipboard As String = Clipboard.GetText
Console.WriteLine("The text on the clipboard was: " & sClipboard)
' //
' --- Set a new text on the clipboard
Dim sNewValue As String = "This is now on the clipboard"
Clipboard.SetText(sClipboard)
Console.WriteLine("The new value is : " & Clipboard.GetText)
' //
Else
Console.WriteLine("Sorry, the clipboard does not contain a text, the demo failed")
End If
End Sub
End Module
C# Implementation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms; // dont forget to add this one
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
if (Clipboard.ContainsText() == true)
{
// Get and display the current clipboard text
string sCurrent = Clipboard.GetText();
Console.WriteLine("The text on the clipboard was: " + sCurrent);
// Set a new value onto the clipboard, and display it to the user
string sNew = "This is now on the clipboard";
Clipboard.SetText(sNew);
Console.WriteLine("The new value on the clipboard is: " + Clipboard.GetText());
}
else
{
Console.WriteLine("Sorry, the clipboard does not contain a text, the demo failed");
}
}
}
}
Posted in VB.NET | Comments Off
January 9th, 2011
The attached zip file is a modified version of the videoplayer block linked in this thread
It uses Flowplayer to playback the files, fixing the aspect problems with the stock videoplayer block included with concrete. An additional modification is this version, is that autplay is turned OFF, while preloading is left ON.
Download the file, and extract it in the blocks directory of your site. While editing pages, choose the VideoPlayer block.
video player for C5 CMS
Posted in Overflow | Comments Off
January 9th, 2011
-- These examples display the use of the JOIN command to select matching
-- or non matching records
-- Written using the AdventureWorks database for SQL Server 2005,
-- The syntax is generic enough to be used on basicaly any version of MS SQL Server
-- or MySQL
-- Display all sales orders
select sh.SalesOrderID, sh.OrderDate, sh.CustomerID from Sales.SalesOrderHeader as sh
-- Display the list of customers that have one or more sales attached
-- Each other that we find for the customer is listed on a seperate line.
-- the LEFT JOIN selects only records from the tables that have a match in BOTH
-- tables, so a Customer with no order attached will NOT be listed.
select cu.* from Sales.Customer as cu
left join Sales.SalesOrderHeader as sh on cu.CustomerID = sh.CustomerID
-- Display the number of sales orders each customer has, sorted by the number of orders.
-- We COUNT the number of records in the SalesOrderHeader table for each unique
-- CustomerID.
-- The group by clause makes sure we list each CustomerID only once
select cu.CustomerID, count(sh.CustomerID) as NumOfSales from Sales.Customer as cu
left join Sales.SalesOrderHeader as sh on cu.CustomerID = sh.CustomerID
group by cu.CustomerID
order by NumOfSales DESC
-- Display the customers that have no sales orders attached
-- the LEFT OUTER JOIN forces the SQL server to include the rows in Sales.Customer regardless of a match
-- in the SalesOrderHeader table. Therefore, we can now select on the CustomerID field being NULL in
-- the SalesOrderHeader tabel.
select cu.* from Sales.Customer as cu
left outer join Sales.SalesOrderHeader as sh on cu.CustomerID = sh.CustomerID
where sh.CustomerID is null
Posted in SQL | Comments Off
January 9th, 2011
Run the following on your master database
SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame
source: http://www.sqlservercurry.com/2008/03/how-to-see-active-connections-for-each.html
Posted in SQL | Comments Off
January 9th, 2011
from: http://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name. Local-url is the (%-encoded) URL of a document on the server relative to the requested directory; it is usually the name of a file in the directory. Several URLs may be given, in which case the server will return the first one that it finds. If none of the resources exist and the Indexes option is set, the server will generate its own listing of the directory.
Posted in Overflow | Comments Off
January 9th, 2011
Create a .htaccess file in the directory you want to protect, it should contain at least the following lines
# Access file
order allow,deny
allow from all
require valid-user
Authname “My Protected Page”
Authtype Basic
AuthUserFile /home/sites/sitename/.htpasswd
Now we want to create the htpasswd file using the htpasswd command in the /usr/sbin/ directory. type:
/usr/sbin/htpasswd -c /home/sites/sitename/.htpasswd username
It will prompt you for the password twice
Next chown the two files to a site-admin username or admin. chmod the files to 755
NOTE: The -c flag in this command signifies that it must create the file. To add further users to the htpasswd file, repeat the same command WITHOUT the -c flag.
To use the server’s /etc/passwd file then the last line of the .htaccess should be:
AuthUserFile /etc/passwd
Please remember that the above example is generic, it will need to be changed to suit your specific needs. Please refer to the extensive documentation available at Apache’s web site for information to assist you in creating the file to suit your needs.
Posted in Overflow | Comments Off
January 9th, 2011
To set the UUID of a Virtualbox vdi harddrive image, run the following command:
VBoxManage internalcommands setvdiuuid mydisk.vdi
Posted in Overflow | Comments Off
January 9th, 2011
Conversion from and to various virtual formats is build into virtualbox, so to convert a virtualbox harddisk image to a virtual pc (or hyper-v) image, run:
VBoxManage clonehd sourcedisk.vdi targetdisk.vhd –format vhd
If you are working on a copy (as you should), you may need to change the UUID of the harddrive
Posted in Overflow | Comments Off
January 9th, 2011
Creating a backup from the command line on the source server
$ mysqldump -h localhost -u username -p database_name > backup_db.sql
Restoring this backup to an existing, empty database on the target server
$ mysql -u username -p database_name < backup_db.sql
Posted in Overflow | Comments Off
January 9th, 2011
This error is usualy caused if you use a proxy server, and the winhttp module is configured for no proxy, or has an incorrect proxy setting.
Start an elevated command prompt by;
Click the start button
Type Command Prompt
Right click the command prompt icon and choose “Run as Administrator”
To review your proxy settings enter the following command:
netsh winhttp show proxy
To reset (clear) your proxy settings enter the following command:
netsh winhttp reset proxy
To configure (set) a proxy enter the following command:
netsh winhhtp set proxy your.proxy.name:proxyport
(or use the direct proxy ip, eg: netsh winhttp set proxy 172.16.128.5:3128)
Additionaly, if you block sites or attachments based on contents, you may need to whitelist the following sites on your proxy so the downloads may pass unhindered:
windowsupdate.microsoft.com
windowsupdate.com
download.microsoft.com
www.update.microsoft.com
Posted in Overflow | Comments Off
January 9th, 2011
source: http://www.intelliadmin.com/index.php/2007/02/create-a-date-and-time-stamp-in-your-batch-files/
Using the ~ substring operator and the %date% or %time% environment variables, it is possible to insert a date or timestamp into a filename while running a batchfile.
testfile_%date:~-4,4%%date:~-7,2%%date:~-10,2%.zip
wil result in something like testfile_20100112.zip
Posted in Overflow | Comments Off
January 9th, 2011
System shutdown on a windows domain controller with MS Exchange installed can take anywhere around 10-15 minutes. This is caused by the fact that the domain services are shutdown before the MS Exchange services, thus causing them to fail repeatedly.
You have two options to tackle this problem;
1. Shutdown the exchange services before shutting down the operating system. (script below)
net stop MSExchangeES
net stop IMAP4Svc
net stop POP3Svc
net stop RESvc
net stop MSExchangeSRS
net stop MSExchangeMGMT
net stop MSExchangeMTA
net stop MSExchangeIS /Y
net stop MSExchangeSA /Y
2. Set the killservices timeout to a lower value then teh default of 10 minutes. The challenge with this option is to make sure you dont set it so low that it will kill services too soon and cause other problems with exchange or other services.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WaitToKillServiceTimeout default: 600000 (10 minutes)
Posted in Overflow | Comments Off