Thursday, 27 September 2012

Silly mistake by me in SQL SERVER

Today I had tried to solved this bug . I have to confess that this take some extra  time by me .

The problem is i create a table name color and insert the field into them and execute this query

select * from color
Black
Blue
Green
Red

After inserting some data i run this query for checking any value is available in it or not

SELECT COUNT(1) color

It seems good becuase i write this query very rapidally and do  not think about this create  a bug?

when i run this it always return 1 . i  am afraid WTF in this .
i spend some time on this but not able to get the error. really i think that is SQL Server corrupted or anything else .
after frustrating i go to took a cup of tea .

and when i came i suddenly saw the error there is mistake of from . i am not using from in my query .
SELECT COUNT(1)  from color

this is silly but happened with me .
Hope this will help you .

ROHIT KUMAR SRIVASTAVA

Thursday, 20 September 2012

Query for getting All Primary key and other constraint in SQL SERVER


Select * from  INFORMATION_SCHEMA.TABLE_CONSTRAINTS pk 
 
WHERE pk.CONSTRAINT_TYPE ='PRIMARY KEY' 

Hope this will help you .
Thanks
ROHIT SRIVASTAVA

Thursday, 30 August 2012

How to handle checkbox check uncheck event with Jquery

Firstly you have to load all jquery file which is required  
 
$('#myform :checkbox').click(function() {


    if ($(this).is(':checked')) {
           
        //Do your work //here check box checked code 
    } else {
        // Do your work // here check box unchecked code 
    }
});

Wednesday, 29 August 2012

How to Call JavaScript function After a time interval with Jquery

use the function  setInterval() like below.
 setInterval(function () {
        YourJavaScriptFunction();
    }, 300000);

Hope this will help you
ROHIT KUMAR SRIVASTAVA

Tuesday, 28 August 2012

What is parsename function in SQL SERVER

Q: What is the parsename function in sqlserver and what is the use of this ?
A:The PARSENAME string function returns the specified part of an object name.
 The PARSENAME() function can be useful for parsing small strings. 

Detail comming soon------------

Monday, 27 August 2012

Difference Between DataSet.Tables.Count() And DataTable.Rows.Count()

We are aware about the DataSet and DataTable . Some time the question arise that what is difference between  DataSet.Tables.Count()  And DataTable.Rows.Count().

The solution is given below .

DataSet.Tables.Count()
-It Gives the number of tables available within a dataset

DataTable.Rows.Count() -
Gives the number of rows available within a datatable.it is basically used for counting total number of rows in a table.

Hope this will help you .
Thanks
ROHIT KUMAR SRIVASTAVA

How to Create Identity Incremented By 2 or any no in SQL SERVER

 Some time we Required when we create a table then auto increment id is increment by even no any specific no .

so the solution is here .
We create a table and i want its auto increment id is like 0 , 2 ,4 etc etc

Create table
create table test ( id int identity(0,2), name varchar(10) )

here in Red color if we increase with no 3 then its like 1,3,6 etc etc

 Select * from test
output  is
id   name 

Insert into test values('ROHIT')
Insert into test values('Riya')
Insert into test values('Immy')

Select * from test
output is
id   name
0    ROHIT
2    Riya
4    Immy

Hope this will help you .
Thanks
ROHIT KUMAR SRIVASTAVA

Wednesday, 22 August 2012

Difference between 2 tier and 3 tier architecture

Some time Question arised that what  is basic difference between 2 tier and 3 tier

Two Tier Architecture: It is nothing but client server Architecture, where client will hit request directly to server and client will get response directly from server.

Three tier Architecture: It is nothing but Web Based application,here in between client and server middle ware will be there, if client hits a request it will go to the middle ware and middle ware will send to server and vise-versa.

Hope this will help you .
Thanks
ROHIT KUMAR SRIVASTAVA

Thursday, 16 August 2012

How to get only month name with SQL Server

declare @start DATE = '2012-04-01'
declare @end DATE = '2012-08-03'

;with months (date)
AS
(
    SELECT @start
    UNION ALL
    SELECT DATEADD(month,1,date)
    from months
    where DATEADD(month,1,date)<=@end
)
select Datename(month,date) from months

Hope this will help you .
ROHIT KUMAR SRIVASTAVA

Difference Between Get And Post method in ASP.Net

So many new programmer are confused about post and get method for send the data. In this article i discuss about this .

The first question arise that what is the get and post method
so many developer confused he/she said that get is used for get the data from server and post  is used for post the data in server this is totally wrong(in starting i am also said this ).
Both Get and Post Method are form submission method.it is used for send the data from client side to server side.

The  Second Question where it is  .
The method is inside the form tag like below
syntax is like below 

<form method="get||post">
you use single method name get or post  

Third Question is ByDefault which method is used 
Ans is By default Get method are used 

Now we discuss these method individually  
What is the difference between these two method 

GET
POST
Data will be arranged in HTTP header by appending to the URL as query string
Data will be arranged in HTTP message body.
Data is in query string so user can view the data
Data is not shown to user
Less secured compared to POST method because data is in query string so it will be saved in browser history and web server logs
safer than GET method because data is not saved in history or web server logs.
As data is saved in URL so its saves only 2048 bytes data
We can used any amount of data and any format
Can be bookmarked
Can’t bookmarked
Hacking will be easy
Hacking is difficult
Only ASCII character data type allowed
No restrictions. Allows binary data also
Caching is possible
No caching

When Use Post Method 
    If the form data is large  then best is use  POST method because GET method cannot      handle long  Url.
   Form data contains Non-ASCII characters use POST because GET doesn’t support it.

Example: Usage of Get method In ASP.NET:
In the below example we will see how GET method passed data from abc.html (client) to login.aspx page (server).
abc.html
<html>
<body>
<form method="get" action="login.aspx">
   User Name: <input id="txtuserName" type="text" name="username" />       
    <input id="btnSubmit" type="submit" value="Submit data using GET" />
    </form>
</body>
</html>
login.aspx
<html>
<body>
    <form id="form1" runat="server">
    <div>
    Welcome <b><% Response.Write(Request.QueryString["username"].ToString()); %></b>
    </div>
    </form>
</body>
</html>




Post Method:
  • We can access form data in ASP.NET using Request.Form["key1"]
 Example: Usage of Post method In ASP.NET:
abc.html
<html>
<body>
<form method="post" action="login.aspx">
   User Name: <input id="txtuserName" type="text" name="username" />       
    <input id="btnSubmit" type="submit" value="Submit data using POST" />
    </form>
</body>
</html>
login.aspx
<html>
<body>
    <form id="form1" runat="server">
    <div>
    Welcome <b><% Response.Write(Request.Form["username"].ToString()); %></b>
    </div>
    </form>
</body>
</html>
Output:
Login.html