Visual Studio: Dude, where is missing UserTasks list?!

9:52

Marek Śliwiński No comments Print This Post  (152)

Recently I reinstalled my comp and VS. When I loaded my project I notest that my all UserTasks from Visual Studio Task List disappeared!

It’s good to know they are all stored in .suo file which is a part of  Solution. So if you use Visual Studio Task List then remember to backup this .suo file also.

Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print

Free e-Book: .NET Coding Guidelines

22:39

Marek Śliwiński No comments Print This Post  (143)

I have downloaded the newest version of well known free documentation tool called GhostDoc and by chance I notest that company which is a owner of GhostDoc made some very nice free e-book about .NET Coding Guidelines (for C#/VB).

There is about 100 pages of good coding practices. You can download e-book (pdf) here (enter as email whatever you want and download will start)

Below table of contents.

Update: There is also another very good document about code styling. Provided by IDesign company and used by great free VS add-in Code Style Enforcer. You can download this doc here
Read more…

Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print
Categories: e-Books Tags: ,

C#: How to add (or use) custom parameters for ASP.NET DataSource controls (SqlDataSource, ObjectDataSource)

14:03

Marek Śliwiński No comments Print This Post  (176)

During work with DataSource controls in Visual Studio one of the common question is how to add some custom data as parameter. There are several pre-definied parameters like SessionParameter, ControlParameter, ProfileParameter etc. but often we need to use something else.

    So let’s for example create custom parameter for username which will be get from User.Identity.Name

A lot of people use _Selecting event of DataSource control to assign suitable data.

In this scenario you have to add empty parameter.

dso_params

Next, add this code into _Selecting event:

  protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        e.InputParameters[0] = User.Identity.Name;
    }

That’s all, that’s fast but it’s not so elegant and reusable as method shown below.

More elegant way
Read more…

Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print
Categories: ASP.NET Tags: ,

Moved from binaryelves.wordpress.com to code.mareoblo.pl

10:28

Marek Śliwiński No comments Print This Post  (88)

Today I finished move from my old blog http://binaryelves.wordpress.com to http://code.mareoblo.pl

I moved from wordpress.com hosting because I would like to have several additional features on my blog, like: syntax highlighter, downloads, feedburner etc.

Since 31-07-2008 when I started to post, my blog was visited 33,798 times with 63 comments added and about 200 visits/day. For me it’s quite satisfy result :)

I would like to thank you all my feed subscribers and all people who add valuable comments on my blog or just say “thx!” for useful piece of code.

Welcome to my new/old blog and enjoy ;)
Read more…

Categories: Other Tags:

How to find some text in any object (table, stored procedure, view,UDF, and more) of SQL Server 2005/2008?

17:39

Marek Śliwiński No comments Print This Post  (511)

Don’t “waste” your time to write or use some custom code, SP etc. Just download this great, freeware tool xSQL Object Search and enjoy his fast work and advanced search options.

This is a standalone file, no installation required.

objectsearchbig

From authors webpage: http://www.xsqlsoftware.com/Product/Sql_Database_Object_Search.aspx

xSQL Object Search is a free SQL tool that provides for locating database objects by checking their names and/or definition against a search criteria. You can search on one or multiple databases simultaneously, select from various search options, search for all or specific objects types, export the results to output files and more. Supports SQL Server 2008 and SQL Server 2005.

Requirements

xSQL Object Search runs on Windows operating systems, client and server, that have the .NET framework 2.0 installed.

Features

Search on one or all databases – choose to find the objects that meet the search criteria on one database or on all databases in the selected SQL Server.

Support all types of database objects – from tables and views to CLR objects and Xml Schema Collections, you can search all database object types.

Search the name or the definition – choose to search on the name of the objects, the T-SQL statement definition of the objects or on both.

A range of search options

  • Exact: Searches for objects whose name or definition is exactly the same as the search text.
  • Starts With: Locates objects whose name or definition starts with the specified search text.
  • Ends With: Locates objects whose name or definition ends with the specified search text.
  • Contains: Locates objects whose name or definition contains the specified search text.
  • SQL Server Expression: Locates objects based a SQL Server expression. Any SQL Server functions and operators that can be used in the “where clause” of a query can participate in the SQL Server Expression criteria.
  • Regular Expression: Locates objects whose name or definition meets a regular expression pattern.

View object definition – view the T-SQL statement that defines the object with a click of a button.

Export search results – easily export the result of the search to a comma-separated-value file.

Simple and intuitive interface – a very simple interface allows you to finish your task with very few clicks. Asynchronous operations provides for a smooth search with status messages and counts.

Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print
Categories: Database Tags:

C#: SQL Server data types equivalents in .NET Framework

17:38

Marek Śliwiński No comments Print This Post  (1,559)

MSDN link:
http://msdn.microsoft.com/en-us/library/ms131092.aspx

And we must remember that .NET DateTime can represent a larger scope of date than the datetime type in SQL Server 2005.

Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print

Transact-SQL: Show real size of tables in database on your harddisk

18:36

Marek Śliwiński No comments Print This Post  (172)

My WSUS database has 1.4 GB size… I was wondering what Microsoft did to achieve this kind of ‘goal’ ;) with just only about 1500 computers inside.  I would like to know which tables take the most space on my HD. That was tbXml with 1GB size… Amazing…

You can find helpful SQL code on Pinal Dave webpage:

http://blog.sqlauthority.com/2007/01/10/sql-server-query-to-find-number-rows-columns-bytesize-for-each-table-in-the-current-database-find-biggest-table-in-database/

Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print

WSUS: T-SQL – Move all computers from Unassigned Computers group into another

16:32

Marek Śliwiński No comments Print This Post  (263)

When recently almost 1500 new computers reported in our WSUS I thought, damn, must to move them from Unassigned Computers group into suitable groups (notebooks, desktops etc.) for easiest management. Unfortunatelly it is a big pain on ass (we don’t use client targeting option in our environment) because of:

- there is no drag & drop in WSUS console (!)

- if you select a lot of computers manually and choose from menu to move them into another group the WSUS Console MMC often start to freeze :/

So.. I look on this 1500 computers and was really in bad mood because of necessity to spend few hours on manually selection (by Ctrl+click) computers and choosing move command from context menu… H+O+R+R+I+B+L+E ;)

Fortunately we have access to WSUS database, so after short investigation and few tries I wrote SQL code which move all computers (selected by you through computer name pattern)  from Unassigned Computers group into group of your choice. After few minutes and few modifications (computer names pattern) the task is done.

I use it on WSUS 3.0 SP1 database. The code is selfexplained I hope. Enter your data in lines with ++++++ Change it to your needs ++++++ comment and run in WSUS database context.

SQL code below.
Read more…

Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print
Categories: WSUS Tags:

C#: WinForms – How to change DataGridView cells color or other attributes

16:30

Marek Śliwiński 1 comment Print This Post  (1,182)

We can use for this _CellFormatting event. See below example:

private void DataGridView1_CellFormatting(object sender,
                        DataGridViewCellFormattingEventArgs e)
{
    DataGridView gv = (DataGridView)sender;

    if (gv.Columns[e.ColumnIndex].Name == "ColumnName")
    {
        // If cell has a value and contains char '-'
        if (e.Value != null && e.Value.ToString().Contains("-"))
        { // Change cell text color to red
            e.CellStyle.ForeColor = Color.Red;
            //e.CellStyle.Font = new Font("Arial", 10, FontStyle.Bold);
        }
    }
}
Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print
Categories: WinForms Tags: ,

Regular Expressions: Remove all special characters from a string, allowing only alphanumeric and chars: ‘.’ and ‘-’

20:28

Marek Śliwiński 1 comment Print This Post  (2,902)

Remove all special characters from a string, allowing only alphanumeric and chars: ‘.’ and ‘-’

Example:

string source = ".ąśę0123^%($&Marek&*(@&@#-";
string result
  = System.Text.RegularExpressions.Regex.Replace(source, @"[^\w\.-]", "");
// result= ".ąśę0123Marek-"
Share and Enjoy:
  • DotNetKicks
  • Digg
  • del.icio.us
  • Wikio IT
  • Google Bookmarks
  • Facebook
  • Print