Monday, 9 January 2012

Difference Json Arrary Vs Json Object ?

JSONArray
A JSONArray is an ordered sequence of values. Its external text form is a string wrapped in square brackets with commas separating the values.
[{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
 {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
 {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
]
 
JSONObject
A JSONObject is an unordered collection of name/value pairs. Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names.

{"bindings": [
 {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
 {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
 {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
 ]
};

How to Optimize Stored Procedure Optimization?

There are many tips and tricks for the same. Here are few:
  • Include SET NOCOUNT ON statement.
  • Use schema name with object name.
  • Do not use the prefix “sp_” in the stored procedure name.
  • Use IF EXISTS (SELECT 1) instead of (SELECT *).
  • Use the sp_executesql stored procedure instead of the EXECUTE statement.
  • Try to avoid using SQL Server cursors whenever possible.
  • Keep the Transaction as short as possible.
  • Use TRY-Catch for error handling.

Which are the Important Points to Note when Multilanguage Data is Stored in a Table?

There are two things to keep in mind while storing unicode data. First, the column must be of unicode data type (nchar, nvarchar, ntext). Second, the value must be prefixed with N while insertion. For example,
INSERT INTO table (Hindi_col) values (N’hindi data’)

Wednesday, 21 December 2011

How to execute DDL command through ADO.Net ?

SqlConnection mySqlConnection = new SqlConnection("Data Source = LocalServer;Initial Catalog=dbAccount;Integrated Security=True;");

SqlCommand mySqlCommand = mySqlConnection.CreateCommand();

mySqlCommand.CommandText = "CREATE TABLE MyEmployee (ID int CONSTRAINT PK_Persons PRIMARY KEY, FirstName nvarchar(15) NOT NULL, LastName nvarchar(15) NOT NULL, DateOfBirth datetime )";

mySqlConnection.Open();

int result = mySqlCommand.ExecuteNonQuery();
        
mySqlConnection.Close();

How do I split a string by a multi-character delimiter in C# ?

string myString = "This is a new sentence.";
string[] _res = myString
.Split(new string[]{ "is" }, StringSplitOptions.None);
for(int i=0; i<_res.length; i++)
    Console.Write(_res[i]);

Tuesday, 20 December 2011

Difference between Repeater, Datalist, GridView

Repeater:
It contains Header Template, Item template , alternate
Item template and footer template. it can't support
Selection, editing, sorting and paging. this is read only
and fast.

Datalist:
It contains Header Template, Item template , alternate
Item template , Edit item template and footer template. it
can't support sorting and paging but support selection and
editing

GridView:
It contains Header Template, Item template , alternate Item
template , Edit item template and footer template. it can
support selection, editing , sorting and paging. Mostly
every developer caught used this control.

                          Repeater  DataList  GridView  ListView
Flow layout         Yes            Yes            No           Yes
Table layout        No             No            Yes           No
Style propertie    No            Yes            Yes           Yes
Column layout     No            Yes            No           No
Paging                  No             No            Yes          Yes
Sorting                 No            No            Yes           Yes
Edit/Delete          No            No            Yes           Yes
Insert                   No            No            No           Yes
Grouping             No           Yes             No            Yes

Friday, 16 December 2011

Why JSON ?

(1) Because JSON is easy to write. It is just like creating and accessing class in javascript in object notation
(2) If you like Generic Class, you will fall in love with JSON.
(3) JSON is just key : value pairs assigned within an object.
(4) JSON is very fast.
(5) It is easy to understand and can be integrated in any web application very easily.
(6) Better organized data if prepared in well mannered way.
(7) On the server-side you can easily serialize/deserialize your objects to/from JSON.
(8) Almost every browser is giving support for JSON.