Archive for April, 2009

.NET: Color Balance

Tuesday, April 21st, 2009

Represents a good control horizontal scroll bar of Windows standard, this screen will see how to change the colors to a panel control by controlling HScrollBar.

colorbalance

Public Class Form1_WiseCodes

 Private Sub Red_HScrollBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Red_HScrollBar.ValueChanged
 ColorPerview_Panel1.BackColor = ColorTranslator.FromOle(RGB(0 + Red_HScrollBar.Value, Green_HScrollBar.Value + 0, 0 + Blue_HScrollBar.Value))
 lblRedValue.Text = Red_HScrollBar.Value
 End Sub

 Private Sub Green_HScrollBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Green_HScrollBar.ValueChanged
 ColorPerview_Panel1.BackColor = ColorTranslator.FromOle(RGB(0 + Red_HScrollBar.Value, Green_HScrollBar.Value + 0, 0 + Blue_HScrollBar.Value))
 lblGreenValue.Text = Green_HScrollBar.Value
 End Sub

 Private Sub Blue_HScrollBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Blue_HScrollBar.ValueChanged
 ColorPerview_Panel1.BackColor = ColorTranslator.FromOle(RGB(0 + Red_HScrollBar.Value, Green_HScrollBar.Value + 0, 0 + Blue_HScrollBar.Value))
 lblBlueValue.Text = Blue_HScrollBar.Value
 End Sub

End Class

Set Values of all the HScrollBar as following . The three arguments (red, green & blue)  must each be in the range 0 to 255.

colorbalance_02

Download Source Code

Happy Programming!!

FTP file upload in .NET 2.0

Friday, April 17th, 2009

It is clear that the FileUpload components, which can be found on the Standard toolbar of Visual Studio 2005 allows uploading files to the remote site, but does not cover all the expectations desired or at least not mine.
So it is interesting to know how we can attack a specific server and an FTP to copy the desired file to the remote location to stay.

To do this:

Step 1: In general declarations establish that the class will use.

C#

using System.Net;

VB.NET

Imports System.Net

Step 2: Create a button in the Click event and write the following code in C# or VB.NET:

C#

private static void wc_UploadFTP(string ftpServerPath, string filename, string username, string password)
 {
WebClient ClientFtp = new WebClient() ;
ClientFtp.Credentials = new NetworkCredential(username, password);
ClientFtp.UploadFile(ftpServerPath + "/" + new FileInfo(filename).Name, "STOR", filename);
}

VB.NET


Private Shared Sub wc_UploadFTP(ByVal ftpServerPath As String, ByVal filename As String, ByVal username As String, ByVal password As String)
 Dim ClientFtp As New WebClient()
 ClientFtp.Credentials = New NetworkCredential(username, password)
 ClientFtp.UploadFile((ftpServerPath & "/") + New FileInfo(filename).Name, "STOR", filename)
End Sub

Happy Programming!!

Visual Studio 2008 Shortcuts

Wednesday, April 15th, 2009

I was asked today about shortcuts in Visual Studio 2008 and have recovered a “old” document listing the essential mouse critics (myself included).

Here I leave the link on the Microsoft page. Click here to Download

visual-studio-2008-shortcuts

Linking remote servers in SQL Server

Monday, April 13th, 2009

To the point:

See the linked servers that have:

exec sp_linkedservers

Add a new remote server to your links:

EXEC sp_addlinkedserver
@ server = 'server'
@ srvproduct ='product_name'
@ provider = 'provider_name'
@ datasrc = 'data_source'

Add credentials to access a remote server:

EXEC sp_addlinkedsrvlogin 'RemoteServerName', 'false', NULL, 'username', 'password'

And Hale, to throw the linked server.

More info on MSDN, here and here.

Happy Programming!!

SQL Server 2005 Tools

Monday, April 6th, 2009

Inside SQL Server 2005 you can find the following tools:

Database Services: Includes the database engine and components of search. The database engine is the core of SQL Server. Replication increases the availability of data among various databases, allowing to scale the workload of each server. The search query language allows level within the data stored in a database.

Analysis Services: Provides functionality for OLAP and Data Mining aimed at Business Intelligence applications. Analysis Services allows you to add data from multiple sources, including relational databases and data work in several ways.

Data Integration Services: Delivery data transformation and integration solutions to extract and process data from multiple sources and directions to one or more destinations. This link allows data from multiple sources and load data in the Data Warehouse.

Notification Services: includes a notification engine and components for customers to create and send personalized messages each time an event occurs. The notifications can be sent to wireless devices like cell phones or PDA’s, or Mail Messenger accounts.

Reporting Services: includes Report Manager and Report Server to provide a complete platform for creating, managing and distributing reports. Report Server is built on standard IIS and technology. NET Framework, allowing lso combine benefits of SQL Server and IIS for hosting and processing reports.

Service Broker: Allows creation of queues and messaging as the core of the database. Queues can be used to stack work, consultations and other applications, and implemented as resources become available. Messaging allows applications that use databases to communicate with them.

Cheers!!!

Sharepoint Designer 2007 Is Now FREE!!

Monday, April 6th, 2009

I just received the excellent news that Sharepoint Designer 2007 is now available as a free download from the Microsoft site. It is NOT a Trial, it is NOT a demo with limited functionality. PRODUCT IS THE RETAIL.

Link to download: Click Here..

Cheers!!!

Disc Burner Windows Image

Sunday, April 5th, 2009

I confess … I have not posted the installation of Windows Server 2008 R2 because I have been all weekend “playing” with Windows 7.

Today browsing my external disks, I found I needed an ISO image to burn, one of the applications that I have not even installed in Windows 7 is PowerISO, but to my surprise brings integrated Windows 7 can burn ISO files.

I think Windows XP that I wanted this ability come integrated into the OS.

I catch them in the process and how easy it is:

discburnerwindows7_01

discburnerwindows7_02

Create Drop Down List Options From Enum

Thursday, April 2nd, 2009

To view the values of an enumeration’s type (enum) to a DropdownList (or other controls with a DataSource property available) is sufficient to bind the following code:

Here’s an example with its own enum (of course also works with system types)

?View Code CSHARP
public enum CountryList
{
Germany = 1,
India = 2,
Japan = 3,
UAE = 4,
USA = 5
}
 
DropdownList1.DataSource = System.Enum.GetValues(typeof(CountryList));

Now, whenever you want to get to The Value of Even enum () method of the enum is useful to get under the VALUE of enum sees below snippet will helpful to
you.

?View Code CSHARP
int intCountry = Convert.ToInt32(System.Enum.Parse(typeof(CountryList), DropdownList1.SelectedItem.ToString());

Read More…

Happy Programming!!

?? Operator (C#)

Thursday, April 2nd, 2009

The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand.
For example:

?View Code CSHARP
int? x = null;
...
// y = x, unless x is null, in which case y = -1.
int y = x ?? -1;

The ?? operator also works with reference types:

?View Code CSHARP
//message = param, unless param is null
//in which case message = "No message"
string message = param ?? "No message";

Source: Click Here…