Archive for the ‘Programming’ Category

How to open Immediate Window In VS 2005- Shortcuts

The Immediate window is used to debug and evaluate expressions, execute statements, print variable values etc.The Immediate window also supports IntelliSense.There are different methods to open Immediate window.

Method 1 : -
We can open Immediate Window from debug menu.

Debug->Windows->Immediate Window

immediate

Some times Immediate Window menu would be missing.If it seems to be missing for you then you can get the Immediate Window menu by going to Tools->Customize and then select the Commands tab, choose for Debug commands and drag Immediate onto the toolbar.Read more about this issue here.

Method 2 : -

Use the Keyboard Shortcut keys Ctrl+Alt+I

Method 3 : -
We can also open Immediate Window through VS Command window.Just type “immed” in the prompt and hit enter Immediate Window will open.

commimmed

For more details about Immediate Window go to MSDN Link

Popularity: 9% [?]

Steps to Create Setup and Deployment Project in Dot Net VS 2008

Step 1
Create your own windows application. Create a new Windows application project in C# and named it as Sample.

d01

Step 2

Design your own application. Here we have a simple login form for example.

d02
Step 3
After completing the design and coding, build the solution of the project in release mode.

d03

Step 4
Check the Release folder for the file “ProjectName.exe”. Here in this example we have the project name as sample so we can find a file with the name Sample.exe. Double click the executable file and check the example.

d04

Step 5
Create a Deployment Project. Select the “Other Project Types” -> “Setup and Deployment” -> “Setup project”. Here we have the setup project for example as “SampleSetup”.

d05

Step 6
Add the Sample.exe project application file inside the “Application Folder”.

d06

Step 7

To make a shortcut for the project right click “File System on Target Machine” and create shortcut of the application. Here in this example the project shortcut is created in program files folder.

d07

Step 8
Create the shortcut of the application.

d08

Step 9
Rename the shortcut of the application.

d09

Step 10
Move the Shortcut file to specified target. Note if you need another shortcut for some other target also create use same steps.

d10

Step 11
Now build the solution in release mode.

d11

Step 12
The setup file created in release folder of the project specified path.

d12

Step 13
Run the setup, step the path to extract.

d13

d14

d15

Step 14
The SampleSetup project is extracted and shortcuts are created. Now run your application.

d16

Popularity: 100% [?]

How to Get The List Of All Tables in a Database – Sql Server 2005

We a can get the list of all tables of a database in different ways : -

1.

SELECT *
FROM sys.TABLES

2.

SELECT *
FROM sysobjects
WHERE TYPE='U'

3.

SELECT *
FROM information_schema.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'

Popularity: 2% [?]

View Existing Triggers – Drop One or More Triggers in Sql Server 2005

To view the existing triggers in the database

SELECT * FROM sys.triggers
OR
SELECT * FROM sysobjects WHERE xtype='TR'

To view the existing triggers in a specified table

sp_helptrigger tablename

To drop a trigger

DROP TRIGGER triggername

To drop more triggers at a time

DROP TRIGGER [trigger1],[trigger2],[trigger3]...[triggern]

Popularity: 7% [?]

Java with JDBC

Combination of java and JDBC is very useful to lets the programmer run his/her program on different platforms. Java programs are secure, robust, automatically downloaded from the network.JDBC API enables Java applications to interact with different types of databases.

Some of the advantages of using Java with JDBC are
• Easy and economical
• Continued usage of already installed databases
• Development time is short
• Installation and version control simplified

JDBC does the following three things
• Establish connection with a database
• Send SQL statements
• Process the results

Popularity: 1% [?]

Java Networking

Network is nothing but a set of computers which are physically connected together.internet is a network of networks.

Protocols:
Different networks requires certain set of rules called protocols.java networking is done using TCP/IP protocol

Different types of protocols are also available in this protocol they are:

*Http(Hyper Text Transfer Protocol)
*FTP(File Transfer Protocol)
*SMTP(Simple Mail Transfer Protocol)
*NNTP(Network News Transfer Protocol)

Sockets:
Sockets is used to plug in just like a electronic sockets.it is essential that they should follow a set of rules to communicate called protocols.
TCP/IP as protocol for communication and IP addresses are the address of the sockets.

Client/Server:
A computer request some service from another computer,is called a client.one that processes the request is called server.A server waits till one of its clients makes a request.it can accept multiple connections at a time.Multi-threading is used to serve multiple users at the same time.

Internet Addresses:

Every computer are connected to a network has a unique IP address.An IP address is a 32-bit number which has four numbers separate by periods.it is possible to connect to the Internet either directly or by using internet service provider.By connecting directly to the internet,the computer is assigned with a permanent IP address.

InetAddress:
InetAddress is one class,which is used to encapsulate th IP address and the DNS.to create a instance of InetAddress class,factory methods are used as there are no visible constructors available for this class.

Methods:

static InetAddress getLocalHost()
//Returns InetAddress object representing local host
static InetAddress getByName(String hostname)
//Returns InetAddress for the host passed to it.

Popularity: 2% [?]

How do you create a Thread

Threads:
Thread is a line of execution.In a single-threaded system there is only one execution line (i.e) only one part of program is in the process of execution at any one time

To create a new thread:

Thread mythread = new thread(this);

this referes the current applet & mythread is a variable

Example:

import java.awt.*;
import java.applet.Applet;
public class MovingBall extends Applet implements runnable
{
Thread mythread=null;
int position=0;
public void start()
{
mythread=new Thread(this);
mythread.start();
}
public void run()
{
while(true)
{
for(position=0;position) {
repaint();
try
{mythread.sleep(100);
}
catch(InterruptedException e)
{
}
}
}
}
public void stop()
{
mythread.stop();
mythread = null;
}
public void paint(Graphics g)
{
g.setColor(Color.gray);
g.fillOval(position,50,30,30);
g.setColor(Color.black);
g.fillOval(position+6,58,5,5);
g.fillOval(position+20,58,5,5);
g.drawLine(position+15,58, position+15,68);
g.drawLine(position+12,68, position+15,68);
g.drawLine(position,45,30,30,-50,-70);
}
}

Popularity: 7% [?]

CASE Function in SQL Server 2005

Sql Case Function :

  • The CASE function allows you to evaluate a column value on a row against multiple criteria, where each criterion might return a different value
  • CASE is just a searched (or lookup) expression – you cannot RETURN from inside it – it’s kind of like IF() in Excel


Sql Case Function has two Types.

  • Simple Function
  • Searched Function

Simple Function :

Syntax :

case @Type
when expression then Result
when expression then Result
else Result

Example for Simple Function:

Set @state=’IND’

Select
state,
case @state
when ‘IND’ then ‘INDIA’
when ‘PAK’ then ‘Pakistan’
when ‘RSA’ then ‘South Africa’
when ‘Lanka’ then ‘Sri Lanka’
end as State Name
from State_name

Result:

State State_name
==== =========
IND INDIA

Searched Function :

Syntax :

case
when boolean_expression then Result
when boolean_expression then Result
else Result

Example for Searched Function:

Table :
Code State
=== ====
1 I
2 IND
3 PAK
4 RSA
5 SL

Select
state,
case
when state in (‘IND’,'I’) then ‘INDIA’
when state in (‘PAK’,'P’) then ‘Pakistan’
when state in (‘RSA’,'SA’) then ‘South Africa’
when state in (‘Lanka’,'SL’) then ‘Sri Lanka’
end as State Name
from State_name

Result :

State State Name
==== =========
I INDIA
IND INDIA
PAK Pakistan
RSA South Africa
SL Sri Lanka

Popularity: 79% [?]

Copy-Paste to and from clipboard using c#

To make the operations such as copy paste using c#,we have to use the Clipboard Class which provides methods to place data on and retrieve data from the system Clipboard.

Example :-

Copy the text from txtCopy to clipboard

 System.Windows.Forms.Clipboard.SetDataObject(txtCopy.Text, true);

Paste the text from clipboard to txtPaste

IDataObject clipData = Clipboard.GetDataObject();
if (clipData.GetDataPresent(DataFormats.Text))
{
txtPaste.Text = clipData.GetData(DataFormats.Text).ToString();
}
else
{
txtPaste.Text = "Could not retrieve data from the clipboard.";
}

Download

Popularity: 41% [?]

Get Clients IP Address Using ASP.NET

We can get the clients IP address using the Request object’s(The Request object retrieves the values that the client browser passed to the server during an HTTP request. ) property Request.ServerVariables Collection.
Request.ServerVariables Collection gets the values of predetermined environment variables.

“REMOTE_ADDR” gets the IP address of the remote host making the request. 

string ipaddr;

ipaddr = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

here the string “ipaddr” stores the clients ip.

List Of other Request.ServerVariables Object

Variable Description
AUTH_TYPE The authentication method that the server uses to validate users when they attempt to access a protected script.
CONTENT_LENGTH The length of the content as given by the client.
CONTENT_TYPE The data type of the content. Used with queries that have attached information, such as the HTTP queries POST and PUT.
GATEWAY_INTERFACE The revision of the CGI specification used by the server. Format: CGI/revision.

HTTP_<HeaderName> The value stored in the header HeaderName. Any header other than those
listed in this table must be prefixed by “HTTP_” in order for the
ServerVariables collection to retrieve its value.

Note: The server interprets any underscore (_) characters in
HeaderName as dashes in the actual header. For example if you specify
HTTP_MY_HEADER, the server searches for a header sent as MY-HEADER.

LOGON_USER The Windows NT® account that the user is logged into.
PATH_INFO Extra path information as given by the client. You can access scripts
by using their virtual path and the PATH_INFO server variable. If this
information comes from a URL it is decoded by the server before it is
passed to the CGI script.
PATH_TRANSLATED A translated version of PATH_INFO that takes the path and performs any necessary virtual-to-physical mapping.
QUERY_STRING Query information stored in the string following the question mark (?) in the HTTP request.
REMOTE_ADDR The IP address of the remote host making the request.
REMOTE_HOST The name of the host making the request. If the server does not have
this information, it will set REMOTE_ADDR and leave this empty.
REQUEST_METHOD The method used to make the request. For HTTP, this is GET, HEAD, POST, and so on.
SCRIPT_MAP Gives the base portion of the URL.
SCRIPT_NAME A virtual path to the script being executed. This is used for self-referencing URLs.
SERVER_NAME The server’s host name, DNS alias, or IP address as it would appear in self-referencing URLs.
SERVER_PORT The port number to which the request was sent.
SERVER_PORT_SECURE A string that contains either 0 or 1. If the request is being handled
on the secure port, then this will be 1. Otherwise, it will be 0.
SERVER_PROTOCOL The name and revision of the request information protocol. Format: protocol/revision.
SERVER_SOFTWARE The name and version of the server software answering the request (and running the gateway). Format: name/version.
URL Gives the base portion of the URL.

Popularity: 10% [?]

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars