Archive for the ‘Programming’ Category

Palindrome For String And Numbers

Palindrome Checking Using C:

#include <stdio.h>
#include <conio.h>
#include <string.h>
#define size 26
 
void main()
{
char strsrc[size];
char strtmp[size];
printf("\n Enter String:= ");
gets(strsrc);
strcpy(strtmp,strsrc);
strrev(strtmp);
if(strcmp(strsrc,strtmp)==0)
printf("\n Entered string \"%s\" ispalindrome",strsrc);
else
printf("\n Entered string \"%s\" is not palindrome",strsrc);
getch();
}

Popularity: 1% [?]

Encrypting string value using MD5 in PHP

The md5 method is used to convert the string value into md5 value.
The syntax is,

string md5 ( string $str [, bool $raw_output ] )

Parameters

str : The string.
raw_output : If the optional raw_output is set to TRUE, then the md5 digest is instead returned in raw binary format with a length of 16. Defaults to FALSE.

For Example,

echo “The MD5 value of ‘ForDevelopers’ is ” . md5(“ForDevelopers”);

Popularity: 3% [?]

Check Sql Server database is Case Sensitive or Insensitive (Collation)

If the collation property of a data base is

1.Latin1_General_BIN its case-sensitive
2.SQL_Latin1_General_CP1_CI_AS or Latin1_General_CI_AI its case-insensitive

There are two ways to find out the SQL Server Database Collation

1. Using DATABASEPROPERTYEX

DATABASEPROPERTYEX gets the current setting of the specified database option or property for the specified database.

Syntax :-
DATABASEPROPERTYEX ( database , property )

SELECT DATABASEPROPERTYEX(‘testdb’, ‘Collation’)

This returns the testdb Database Collation property value say if this testdb is a case-sensitive database then it returns

Latin1_General_BIN

2.Using Sql Server Management Studio

Step 1 : Open Sql Server Management Studio.

Step 2 : Right Click on database and click its properties


After clicking the properties you get a database properties modal box such as

The red box shows the collation property value of that database.

Popularity: 5% [?]

Encrypting text value using MD5 in Dot Net

For example we will have two textboxes such as ‘TextBox1′ and ‘TextBox2′.Now we will encrypt ‘TextBox1′ value using MD5 in Dot Net and display the encrypted value in ‘TextBox2′.

string pwd = “”;
 
pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text, “MD5″);
 
TextBox2.Text = pwd;

Popularity: 1% [?]

Open a File in Runtime in Java

Open a File in Runtime in Java:

1.Create a Object For Process

2.exec is a method to open a File in Runtime

3.In the exec Method, we can give all the command which can be give in the Run Window

Process process=Runtime.getRuntime().exec(“notepad d:\demo.txt”);

4.If it cannot Work,Copy Exe File and Paste it in C:\Windows\System32

Popularity: 1% [?]

Conditional Tags in JSP

The if tag allows the conditional execution of its body according to the value of the test attribute

<c:if test=”${not empty details.add}”>
It is Not a Empty ArrayList
</c:if>

<c:if test=”${empty details.add}”>
It is a Empty ArrayList
</c:if>

The choose tag performs conditional block execution by the embedded when subtags. It renders the body of the first when tag whose test condition evaluates to true. If none of the test conditions of nested when tags evaluates to true, then the body of an otherwise tag is evaluated, if present.

<c:choose>
<c:when test=”${bank.account== ‘saving’}”>
Saving Account
</c:when>
<c:when test=”${bank.account == ‘RD’}”>
RD Account
</c:when>
<c:when test=”${bank.account == ‘salary’}”>
Salary Account
</c:when>
<c:otherwise>

</c:otherwise>
</c:choose>

Popularity: 3% [?]

SQL Server Connection Using Integrated Security

When we are connecting sql server using windows authentication then we do not need to give the user name and pwd in the connection string. We have to provide the Integrated Security property to true.

SqlConnection con = new SqlConnection(“Server=servername;Integrated Security=true; Database=emp”);

Note : If your sql server is of windows authentication and if you dont provide Integrated Security you may get an error such as follows
Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.

Popularity: 1% [?]

Function To Generate Random Password using C#

usually you would send a random generated password while user does the registration process through your application.You can use the following code to achieve that.

public string Generate_Password()
{
string Password = “”;
byte Cnt, Idx;
string values = “0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
Random rnd = new Random();
for (Cnt = 1; Cnt &lt;= 6; Cnt++)
{
Idx = (byte)rnd.Next(0, values.Length);
Password += values.Substring(Idx, 1);
}
return Password.Trim().ToUpper();
}

To Generate Random Password we have used the Random Class(Namespace:-System).To learn more about Random Class have a look at this MSDN LINK.

Popularity: 4% [?]

What is Delegate?

A delegate is a type that references a method.Once a delegate is assigned a method, it behaves exactly like that method. The delegate method can be used like any other method,with parameters and a return value.

Any method that matches the delegate’s signature,which consists of the return type and parameters,can be assigned to the delegate.

Delegates allow methods to be passed as parameters.It can be used to define callback methods.

Popularity: 1% [?]

What is ViewState ?

ASP.NET view state is the technique used by an ASP.NET Web page to persist
changes to the state of a Web Form across postbacks.That is when a form is submitted in ASP .NET, the form reappears in the browser window together with all form values.

The ViewState indicates the status of the page when submitted to the server. The status is defined through a hidden field placed on each page with a <form runat=”server”> control.

Hidden field placed on each page would be something as this
< input type=”hidden” name=”__VIEWSTATE” value=”CEbzzzEnmmz+Bc8IDFlnpgCLJ/HB00.” >
Maintaining the ViewState is the default setting for ASP.NET Web Forms. If you want to NOT maintain the ViewState, include the directive l%@ Page EnableViewState=”false” %> at the top of an .aspx page or add the attribute EnableViewState=”false” to any control.

Popularity: 1% [?]

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