c#

How to Get the Datas From Sql Server To Bootstrap Datatable Using Asp.net C#?

ScreenShot:

untitled

screen32.png

Scripts:

 <meta name=”viewport” content=”width=device-width, initial-scale=1″ />
<link href=”http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&#8221;
rel=”stylesheet”>
http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js
https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js
<link rel=”stylesheet” href=”http://cdn.datatables.net/1.10.2/css/jquery.dataTables.min.css&#8221; />
http://cdn.datatables.net/1.10.2/js/jquery.dataTables.min.js

<style>

.panel {
padding: 15px;
margin-bottom: 20px;
background-color: #ffffff;
border: 2px solid #57BC90;
border-color:#57BC90;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);

}

.panel-heading {
padding: 10px 15px;
margin: -15px -15px 15px;
font-size: 17.5px;
font-weight: 500;
background-color:#6c7a89;
border: 1px solid #e4287e;

border-bottom-color:#e4287e;

}

.panel-footer {
padding: 10px 15px;
margin: 15px -15px -15px;
background-color: #f5f5f5;
border-top: 1px solid #dddddd;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
.panel-body
{
background-color: #ffffff;
border: 2px solid #57BC90;
border-color:#57BC90;

}

.siz
{
padding-left:10px;
padding-top:30px;
padding-right:10px;
}

.clr
{
color:#57BC90;
}

hr.style-one {
border: 0;
height: 55px;
margin-left:33%;
background-image: url(img/type_1.png);
background-repeat: no-repeat;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
box-sizing: border-box;
display: inline-block;
min-width: 1.5em;
padding: 0.5em 1em;
margin-left: 2px;
text-align: center;
text-decoration: none !important;
cursor: pointer;
*cursor: hand;

color: #333 !important;
border: 1px solid transparent;

}

//Reponsive From My Css

@media screen and (max-width: 600px),(max-width: 760px), (min-device-width: 768px) and (max-device-width: 1024px)
{

table td + td + td + td + td + td + td + td + td + td + td {
border: none;
word-break: break-all;
}
.footable
{

clear: both;
margin-bottom: 6px !important;
max-width: none !important;
table-layout: fixed;
word-break: break-all;
}

thead {
display: none;
}

tr {
margin-bottom: 20px;
display: block;
border-bottom: 2px solid #ddd;
border: 2px solid #57BC90;
border-color:#57BC90;
}

td {
display: block;
text-align: right;
font-size: 13px;
border-bottom: 1px dotted #ccc;
}

td:last-child {
border-bottom: 0;
}

tr:nth-of-type(2n)
{
background-color: inherit;
}

tbody td
{
display: block;
text-align: center;
border-collapse: separate;

}
tbody td:before
{
content: attr(data-th);
display: block;
text-align: left;
color:#e4287e;

}

//Add Header To Datatable Reponsive
/*
Label the data*/

td:nth-of-type(1):before
{
content: “ID”;

}
td:nth-of-type(2):before
{
content: “First Name”;
}
td:nth-of-type(3):before
{
content: “Last Name”;
}
td:nth-of-type(4):before
{
content: “Fees Paid”;
}
td:nth-of-type(5):before
{
content: “Gender”;
}
td:nth-of-type(6):before
{
content: “Email Id”;
}
td:nth-of-type(7):before
{
content: “Telephone Number”;
}

td:nth-of-type(8):before
{
content: “Date Of birth”;

}

td:nth-of-type(9):before
{
content: “Is Active”;

}

td:nth-of-type(10):before
{
content: “Creation Date”;

}

td:nth-of-type(11):before
{
content: “last Modified Date”;

}

}
</style>

$(document).ready(function () {
$(‘#example’).DataTable({
“paging”: true,
“ordering”: true,
“info”: true

});
});

Body Tag:

<form id=”form1″ runat=”server”>


Delete selected Row
–%>

Students Portal


–%>–%>

ID First Name Last Name Fees Paid Gender Email Id Telephone Number Date Of Birth Is Active Creation Date last Modified Date
Total:
ID First Name Last Name Fees Paid Gender Email Id Telephone Number Date Of Birth Is Active Creation Date last Modified Date

</div>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
</div>
</div>
</div>
</div>
</form>

 

 

Cs File:

 

 

protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(“Data Source=ARAVIND;Initial Catalog=aravind;User ID=xxx;Password=test123;”);

DataSet dataset = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(“select * from tbl_Datatable1”, con);
da.Fill(dataset, “tbl_Datatable”);

rptOscarNominees.DataSource = dataset;
rptOscarNominees.DataBind();
}

 

 

Uncategorized

Sql My Preparation

CREATE DATABASE:

* CREATE DATABASE ARAVIND;

DROP DATABASE:

* DROP DATABASE ARAVIND;

RENAME DATABASE:

* ALTER DATABASE ARAVIND MODIFY=BALA;

CREATE TABLE:

—->    CREATE TABLE TABLE_BALA(
INT INTEGER IDENTITY PRIMARY KEY,
NAME NVARCHAR(50),
PLACE NVARCHAR(50),
ADDRESS VARCHAR(50),
SALARY DECIMAL(18,2),
PHONEnUMBER VARCHAR(30),
EMAIL VARCHAR(320))     ——>

RENAME TABLE:

* SP_RENAME ‘OLD_TABLE_NAME’,’NEW_TBL_NAME’

DELETE TABLE:

* DELETE TBL_BALA WHERE ID=1  <-EXAMPLE

TRUNCATE TABLE:

* TRUNCATE TABLE TBL_BALA

DROP TABLE:

* DROP TABLE TABLE_BALA

COPY TABLE TO ANOTHER TABLE:

* SELECT * INTO TBL_DEMO FROM TBL_BALA

LOCAL TABLE SAVE TEMPDB DATABASE:

—->CREATE TABLE #LOCAL_TABLE_DEMO(
ID INTEGER,
NAME NVARCHAR(30),
PLACE NVARCHAR(30))<——-

GLOBAL TABLE:

—->CREATE TABLE ##GLOBAL_TABLE_DEMO(
ID INTEGER,
NAME NVARCHAR(3),
PLACE NVARCHAR(3))<——

RENAME TABLE COLUMN VALUE:

* SP_RENAME ‘TBL_DEM.PLACE’,’AREA’,’COLUMN’;

SELECT:

* SELECT * FROM TBL_BALA

SELECT PARTICULAR COLUMN:

* SELECT PLACE FROM TBL_BALA

dISTINCT sELECT:

* SELECT DISTINCT PLACE FROM TBL_BALA;

SELECT COUNT:

*SELECT COUNT(NAME) FROM TBL_BALA
*SELECT COUNT(*) FROM TBL_BALA
*SELECT COUNT(DISTINCT NAME) FROM TBL_BALA

SELECT TOP,FIRST,LAST CUSTOMRS:

*SELECT TOP 2 * FROM TBL_BALA
*SELECT FIRST(FLD_NAME) AS NAME FROM TBL_BALA

SELECT aS:

*TEMPORARY NAME

SELECT FLD_NAME AS NAME,
PLACE AS AREA,
pHnO,
eMAIL FROM TBL_BALA;

SELECT iN:

* REDUCE OR OPERATIONS

SELECT * FROM TBL_BALA WHERE NAME IN(ARAVIND,BALA,AB)

JOIN:

INNER JOIN:

* SELECT TBL_CUST.PLACE,TBL_CUST.NAME,TBL_SUP.PHNO,TBL_SUP.AMOUNT FROM TBL_CUST INNER JOIN TBL_SUP ON TBL_CUS.ID=TBL_SUP.ID;

lEFT jOIN:

* SELECT TBL_CUST.PLACE,TBL_CUST.AMOUNT,TBL_SUP_MAIL,TBL_SUP.DATE FROM TBL_CUST LEFT OUTER JOIN TBL_SUP ON TBL_CUST.ID=TBL_SUP.ID;

rIGHT jOIN:

* SELECT TBL_CUST.ADRESS,TBL_CUST.NUMBER,TBL_SUP.EMPnO,TBL_SUP.JOIN FROM TBL_CUST RIGHT OUTER JOIN TBL_SUP ON TBL_CUST.ID=TBL_SUP.ID;

fULL JOIN:

* SELECT TBL_CUS.NAME,TBL_CUS.PLACE,TBL_SUS.PHNO,TBL_SUS.MAIL FROM TBL_CUS FULL OUTER JOIN  TBL_SUS ON TBL_CUS.ID=TBL_SUS.ID;

* select * from tbl_login as lo full outer join tbl_detailsof d on lo.fld_id=d.fld_id;

lIKE,wILDCARD:

HAVING ONLY TWO METHODS(‘_’,’_%’)

* SELECT * FROM TBL_BALA WHERE SALARY LIKE ‘200%’;
* SELECT * FROM TBL_BALA WHERE SALARY LIKE ‘_400’;

uNION:

* COMBINES TWO  TABLE RESULTS…ITS CONTAIN TWO OR MORE WHERE STATEMENTS

SELECT JOIN_CUS.NAME,JOIN_CUS.PLACE,JOIN_SUP.PHNO FROM JOIN_CUS LEFT OUTER JOIN JOIN_SUP ON TBL_CUS.ID=TBL_SUP.ID

UNION

SELECT JOIN_CUS.NAME,JOIN_CUS.PLACE,JOIN_SUP.PHNO FROM JOIN_CUS RIGHT OUTER JOIN JOIN_SUP ON TBL_CUS.ID=TBL_SUP.ID

uNION aLL:

* SELECT JOIN_CUS.NAME,JOIN_CUS.PLACE,JOIN_SUP.PHNO FROM JOIN_CUS LEFT OUTER JOIN JOIN_SUP ON TBL_CUS.ID=TBL_SUP.ID

UNIONALL

SELECT JOIN_CUS.NAME,JOIN_CUS.PLACE,JOIN_SUP.PHNO FROM JOIN_CUS RIGHT OUTER JOIN JOIN_SUP ON TBL_CUS.ID=TBL_SUP.ID

CREATE unique  INDEX idx_FLD_nAMeeu on  TBL_DETAILSOF (FLD_nAME);

iNDEX:

* select *   from TBL_DETAILSOF with(index(idx_FLD_nAM))

* SELECT * FROM TBL_USERS

fUNCTIONS:

* SELECT substring (‘ABARAVIND05’,9,4)

* SELECT datalength(‘                     GREGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG’);

* SELECT len(‘         DEWWWWW     ‘)

* SELECT  Len (NULL) AS FE

* SELECT lower(‘fggggggegefgvwfergekijfwbfwjfbwfjwfgwfwfwefdwe’)

* SELECT ltrim(‘           DVDFGVV             ‘)

* SELECT rtrim(‘    V   KHHH                ‘)

* SELECT  nchar(66)

* SELECT replace(‘JHNHBGNHJHNNMLMKJ’,’J’,’9′)

*   select substring (convert(NVARCHAR(30), getdate(), 120), 1, 16 )     ——get current time and date

* —–space used –** sp_spaceused tbl_detailsof

* find page type——-dbcc ind(‘aravind’->(database name),’tbl_detailsof’,-1)

* select * from sysobjects,select * from sys.object ,select * from information_schema.tables,select * from sys.tables, select * from sys.procedures

sUB qUERY:

* SELECT U.NAME,U.AGE,U.PH FROM TBL_DETAILSOF WHERE FLD_NAME NOT IN(‘ARAVIND’,’AB’,’BALA’)

* sELECT NAME,AGE,(SELECT FLD_PLACE FROM TBL_USER U WHERE FLD_ID=1) FROM TBL_DETAILSOF D WHERE D.FLD_ID=1;   LIKE JOIN

trigger:

* FIRST OF ALL WE CREATE A TWO TABLES LIKE THAT—>CREATE TABLE TBL_TRIGDEMO(ID IDENTITY PRIMARY KEY,NAME NVARCHAR(50),CITY NAVRACHAR(50))
AND SECOND tABLE iS –> CREATE TABLE TBL_TRIGG(ID INTEGER,NAME NVARCHAR(50),CITY NVARCHAR(50), AUCTION NVARCHAR(100),SE_TIMESTAMP DATETIME)

tRIGGERS:

*aFTER tRIGGER

* iNSTEAD OF tRIGGER

aFTER tRIGGER:

* CREATE TRIGGER TRGDEMO ON TBL_TRIGDEMO
FOR UPDATE
AS DECLARE @IN_ID INTEGER,@IN_NAME NVARCHAR(50),@IN_CITY NVARCHAR(50),@IN_ACTION VARCHAR(100)
SELECT @IN_NAME=I.NAME FROM INSERTED I;
SELECT @IN_CITY=I.NAME FROM INSERTED I;

IF UPDATE(NAME)

SET @IN_ACTION=”UPDATE TRIGGER”

IF UPDATE(CITY)

SET @IN_ACTION=”UPDATE TRIGGER”

INSERT INTO TBL_TRIGG(NAME,CITY,ACTION,TIMESTAMP) VALUES (@IN_NAME,@IN_CITY,@IN_ACTION,GETDATE());

PRINT “AFTER UPDATE”

cOPY ANOTHER DATABASE TABLE DATA TO ANOTHER DATABASE DATA:

eXAMPLE:    select * into nEWtABLE  from AB.DBO.EMPLOYEE

IMAGE SAVE IN DATABASE:

insert into TBL_IMGSAVE (IMAGEsAVE) select bULKcOLUMN from openrowset(bulk ‘e:\IMG\KLOOP.JPG’, single_blob)AS IMAGE;

ALTER TABLE NEW COLUMN  ADD :

ALTER TABLE TBL_NEW ADD FLD_NAME NAARCHAR(50)

/**——————-iMAGE SAVE IN SQL DATABASE————–**/

EXAMPLE

INSERT  TBL_TUTORIAL (FLD_ID,FLD_fNAME,FLD_lNAME,FLD_EMAIL,FLD_PHONE,FLD_CITY,IMGSAVE)
SELECT ‘8’ FLD_ID ,’SIVA’ FLD_fNAME ,’KUMAR’ FLD_lNAME,’SIVAKUMARDB@GMAIL.COM’ FLD_EMAIL,’8725963148′ FLD_PHONE,’CHENNAI’ FLD_CITY,
bULKcOLUMN from openrowset(bulk ‘e:\IMG\KLOOP.JPG’, single_blob) as IMGSAVE

Uncategorized

Collections in C#: ArrayList and Arrays

Introduction:

Mirosoft.Net has many namespaces for different purposes. Among them the System.Collections is a very important namespace in the programmers perceptive. While coding, we look for classes that can reduce manual operation. For instance if you want to sort the values in an array then you have to do the manual operations. Here obviously we look for the classes that can automate the sorting by just calling a method. In other words we can call this namespace as a utility namespace. Let us see the classes in this namespace.

Collection Classes:

The System.Collections namespace has many classes for the individual purpose. We are going to discuss the frequently used classes in this article.

  • ArrayList
  • BitArray
  • Stack
  • Queue
  • Comparer
  • HashTable
  • SortedList

 

ArrayList:

The ArrayList is one of the important classes in the System.Collection namespace. We can say it is the next generation of the Array in C#.

 

ArrayList is a dynamic array; it will increase the size of the storage location as required. It stores the value as object. The allocation of the ArrayList can be achieved through the TrimToSize property.

 

Methods:

1 Add It will add the element as object in the ArrayList
2 AddRange It will add the collections of elements in the object as individual objects in the ArrayList
3 Clear It will clear the all objects in the ArrayList
4 BinarySearch It will return the position of the search object as integer value.
5 Insert It will insert the element in the specified location of the index in the ArrayList.
6 InsertRange It will insert the elements in the object as individual objects in the specified location.
7 Remove It will remove the given object in the first occurrence in the ArrayList.
8 RemoveAt It will remove the object as specified in the argument.
9 RemoveRange It will remove the set of objects in the ArrayList from the range specified.
10 Sort It will do the sorting of the elements in the ascending order.
11 Reverse It will arrange the elements in the reverse order in the ArrayList.
12 GetEnumerator It will return the collection of objects in the ArrayList as enumerator.
13 Contains It checks whether the objects exists or not.

 

Add:

This Add method is used to add an object to the ArrayList. Whatever we add element to the ArrayList then it consider as an object.

Let us see how to add element into ArrayList.

ArrayListObject.Add(element);

For example:

ArrayList oArrayList = new ArrayList();

oArrayList.Add(“senthil”);

oArrayList.Add(“Kumar”);

oArrayList.Add(99);

oArrayList.Add(“@”);

oArrayList.Add(“55.55”);

oArrayList.Add(oStack);
Here, I have added a few elements that everything considers as an object. Elements can be duplicates or you can add null into the ArrayList. The size will be expanded when you insert new elements.

Add Range:

The Add range method will add elements from other collections. Here the elements can be null, but the Add range collection cannot be null.

Consider this example for better understanding.

Stack oStack = new Stack();

oStack.Push(1);

oStack.Push(2);

oStack.Push(3);

oStack.Push(4);

 

ArrayList oArrayList = new ArrayList();

oArrayList.Add(“Senthil”);

oArrayList.Add(“Kumar”);

oArrayList.AddRange(oStack);
Here what happens, when you add the Stack object it considers as one of the element in the ArrayList. But when you use AddRange method it stores the elements in the Stack as individual elements in the ArrayList.

It adds the elements at the end of the ArrayList.

Here the output will be like the following.

Senthil  kumar 1 2 3 4

 

Clear:

Clear method is used to clear the elements in the ArrayList.

ArrayListObject.Clear();

ArrayList oArrayList = new ArrayList();

oArrayList.Add(“c#”);

oArrayList.Add(“Java”);

oArrayList.Add(“PHP”);

If you see the total elements in the ArrayList it is 3. You can check with the Count property.

Here I clear the ArrayList.

oArrayList.Clear();

Now count of the ArrayList is 0. However the Capacity remains the same as set.

 

BinarySearch:

The BinarySearch method is used to get the location of the object in the ArrayList.

It uses the Binary search algorithm to find the elements. It will return the element position in the ArrayList. Here the object can be a duplicate, in that case it will return the position of any one of the occurrences of the element.

Consider the following example,

ArrayList oArrayList = new ArrayList();

oArrayList.Add(1);

oArrayList.Add(3);

oArrayList.Add(5);

oArrayList.Add(7);

int iPos = oArrayList.BinarySearch(3);

Here it will return the location of the index value into the integer variable.

Insert:

The Insert method is used to insert the new element in the existing ArrayList. This is new specific feature in the ArrayList when you compare with the Array. Here it uses the LinkedList, when you insert the element then it will move the node.

The syntax of the Insert method follows.

ArrayListObject.Insert(Position,Object);

Consider this example for the better understanding.

ArrayList oArrayList = new ArrayList();

oArrayList.Add(1);

oArrayList.Add(3);

oArrayList.Add(4);

If you check the ArrayList, elements will be stored like this.

1 3 4

Let us insert a new element in the position of 2.

oArrayList.Insert(2,2);

Now we have inserted the element in the ArrayList.

After insertion, the output will be like the following.

1 2 3 4

InsertRange:

InsertRange method is used to insert the collection of the elements in the other collections from the specified index position. Here it will insert the individual object from the collection object.

ArrayListObject.InsertRange(Position,CollectionObject);

Let us see with an example.

ArrayList oArrayList = new ArrayList();
oArrayList.Add(1);
oArrayList.Add(5);
oArrayList.Add(6);

If you check the output of the ArrayList it will be like the following.

1 5 6

Now I am going to insert the collection object.

Stack oStack = new Stack();
oStack.Push(2);
oStack.Push(3);
oStack.Push(4);
oArrayList.InsertRange(2,oStack);

We have inserted the range of elements from the Stack.

Now output of the ArrayList will be like the following.

1 2 3 4 5 6

Remove:

The Remove method is used to remove the element from the ArrayList. If there are multiple objects in the same name when you try to remove, then it will remove the first occurrence in the ArrayList. In case of no elements found then it will not throw an exception and ArrayList count remains the same.

The syntax of the Remove method as given below.

ArrayList oArrayList = new ArrayList();
oArrayList.Add(“Senthil”);
oArrayList.Add(“Kumar”);
oArrayList.Add(“Senthil”);
oArrayList.Remove(“Senthil”);

Here it will remove the first element in the ArrayList.

RemoveAt:

The RemoveAt method is used to delete the specified location element in the ArrayList.

The syntax of the RemoveAt method is given below.

ArrayListObject.RemoveAt(ArrayListIndex);

Let us see an example,

ArrayList oArrayList = new ArrayList();
oArrayList.Add(“Senthil”);
oArrayList.Add(“Kumar”);
oArrayList.Add(“Senthil”);
oArrayList.RemoveAt(1);

Here the second element will be removed from the ArrayList.

 

RemoveRange:

The RemoveRange method is used to remove the collection of objects in the ArrayList.

It removes the range of Starting position to number of elements specified in the RemoveRange method.

ArrayListObject.RemoveRange(Starting Index, Number of objects);

Let us see an example for better understanding.

ArrayList oArrayList = new ArrayList();
For(int i=1;i<10;i++)
{
oArrayList.Add(i);
}

Here 10 elements will be added as object in the Array List.

I am going to delete 3 elements starting from 5.

oArrayList.RemoveAt(5,3);

Now the output will be like the following.

1 2 3 4 8 9 10

Sort:

The Sort method is used to sort the objects in the ascending order. It uses the QuickSort algorithm to sort the elements in the ArrayList.

ArrayListObject.Sort();

Let us see an example.

oArrayList.Add(“B”);
oArrayList.Add(“A”);
oArrayList.Add(“Z”);
oArrayList.Sort();

The output of the above ArrayList will be like this.

A B Z

Reverse:

The Reverse method is used to arrange the objects in the Reverse order.

ArrayListObject.Reverse();

Let us see an example.

oArrayList.Add(“A”);
oArrayList.Add(“B”);
oArrayList.Add(“C”);
oArrayList.Reverse();

Before the reverse method

A B C

After the revserse method

C B A

 

GetEnumerator:

The GetEnumerator method is used to get the collection of the objects in the ArrayList as Iterator. This can be implemented with suitable interface. Howevery the ArrayList elements can be iterated through the foreach or loop statements.

Let us consider the following example code snippet.

oArrayList.Add(“B”);
oArrayList.Add(“A”);
oArrayList.Add(“Z”);
IEnumerator OIEnum = oArrayList.GetEnumerator();

Contains:

This method is used to check whether the element exists or not. It returns the Boolean result.

OArrayList.Contains(“Senthil”)

Properties in the ArrayList

S.No Property Name Description
1 Capcity This property is used to set or get the size to the ArrayList.

As you know it will increase the size of the storage as much as required. Default size will be 16.

2 Count It returns the total number of elements in the ArrayList.
3 IsFixedSize It returns the Whether the ArrayList is fixed size or not. It returns the Boolean value.
4 IsReadOnly It returns the Whether the ArrayList is Readyonly or not. It returns the Boolean value.

 

Advantages:

  • The ArrayList is not a specific data type storage location, it stores everything as object.
  • No need to do allocation and deallocation explicitly to store the data.
  • It has the explicit sorting methods.
  • It can insert and delete the elements in between positions in the ArrayList.
  • It can store the object as elements.

Disadvantages:

  • ArrayList is not a strongly typed one. It has to do the type casting when you retrieve the content. When we do the type casting every time, it hits the performance.
  • It uses the LinkedList storage approach, because if you insert or delete the specific position it has to forward/backward in the storage address.
  • Sometimes it leads to the runtime error. Consider an example, we store the ids of the employee in the arraylist and then we want to retrieve the element for some other operations. Obviously we need to do the type casting, that time if there is any string element then what will happen? It will throw the error.

Difference between Array and ArrayList

Array ArrayList
Array uses the Vector array to store the elements ArrayList uses the LinkedList to store the elements.
Size of the Array must be defined until redim used( vb) No need to specify the storage size.
Array is a specific data type storage ArrayList can be stored everything as object.
No need to do the type casting Every time type casting has to do.
It will not lead to Runtime exception It leads to the Run time error exception.
Element cannot be inserted or deleted in between. Elements can be inserted and deleted.
There is no built in members to do ascending or descending. ArrayList has many methods to do operation like Sort, Insert, Remove, BinarySeacrh,etc..,

 

Conclusion:

So far we have seen the ArrayList and its members and properties. I hope that this has given enough practical idea about the ArrayList. Next we are going to discuss about the BitArray in the same collection class. If you have any query or further clarifications about this ArrayList please free to post your feedback and corrections.

Uncategorized

What is the difference between a mutex and a semaphore?

Mutex:

Is a key to a toilet. One person can have the key – occupy the toilet – at the time. When finished, the person gives (frees) the key to the next person in the queue.

Officially: “Mutexes are typically used to serialise access to a section of  re-entrant code that cannot be executed concurrently by more than one thread. A mutex object only allows one thread into a controlled section, forcing other threads which attempt to gain access to that section to wait until the first thread has exited from that section.”

(A mutex is really a semaphore with value 1.)

Semaphore:

Is the number of free identical toilet keys. Example, say we have four toilets with identical locks and keys. The semaphore count – the count of keys – is set to 4 at beginning (all four toilets are free), then the count value is decremented as people are coming in. If all toilets are full, ie. there are no free keys left, the semaphore count is 0. Now, when eq. one person leaves the toilet, semaphore is increased to 1 (one free key), and given to the next person in the queue.

Officially: “A semaphore restricts the number of simultaneous users of a shared resource up to a maximum number. Threads can request access to the resource (decrementing the semaphore), and can signal that they have finished using the resource (incrementing the semaphore).”

Uncategorized

Things you need to remember to become a successful developer… Andriy Buday

8 outstanding points which will help you become a successful developer

1. Keep on learning

I assume that you would not even read this blog without having some elementary education and you would not want to know how to become a successful developer without higher education. So while you are right now a developer, why stop learning?
There is no way to do that. One important thing here: Staying in one place doesn’t mean you are staying there – it means you are moving backward. Walking forward doesn’t mean you are moving forward – it means at least that you are not lost with the losers in the end. To keep going forward, you need to learn continuously – not to walk, but RUN!
Here is my short list:

  • Read books
  • Subscribe to RSS Feeds and read magazines
  • Try out different features you hear about
  • Go to seminars and do your own presentations
  • Learn everything that can help you move
  • Teach others since this teaches you 

2. Establish what your goal is and keep the right way

Ok, it could be hard to run without knowing where to run. The key point here is that you need to clearly imagine your goal. This goal should be a long term target, and after you have a vision of your goal, go ahead and break it down into smaller tasks – build your roadmap. You may create a list of tasks you MUST accomplish per month or per year. Then just follow it.

3. Every challenge is an opportunity

In everyday work, you always encounter different troubles. You get issues and bug reports from your QA. You get new tasks from your Project Manager. Your co-worker is asking for help. You need help. These are all challenges. And the real question is: how do you meet them? I have an answer: you need to take them all with passion, because every challenge is the opportunity. You would say “Hey, but this way I will never get off stupid nasty work.” You are 100% not right here. Remember your bosses will be glad to give you more complicated work once they see you do the best to get your current job done.

4. Be positively charged

You should look at everything in a very positive manner. If it is found that you made a mistake, just take it easy – everyone makes them. Do you like people who start to whine once they have troubles? How do you think you will be looking in others’ eyes if you will just say “Ok, guys, I did it – I will solve this, give me a minute.” and turn around and start fixing your mistake with a smile on your face. After you solve the problem, you will be so happy that you could not even imagine.
Your method is good and you are moving fast forward. Don’t ever, ever think that you will not be able to reach your goal.

5. Find a mentor

This does not mean that you a need a person who will help you in doing your job – it is a coach or a more senior staff then you are. This means that you need a person who stays where you want to be and you need to take a leaf from his/her book. And if he will not be high enough – you will need to find another. But all the time you need to have that person. Also have people, friends if you will, who will help you keep on track. It could be your wife or girlfriend (in my case Smile | :) ), or best friend who always supports you (in my case he is a developer, but this doesn’t matter).

6. Be more public

If you will not show others that you are cool and you deserve more, how will they know? There is simple way to do that – start blogging, ask and answer questions, ensure Google knows something about you. Share your knowledge in your team and project. If you learned something new, why do not share it. You will forget it if will not be trying it.

7. Track your activities; be sure that you are on track

Time to time, you need to check if you are doing all the right methods. Verify if you are accomplishing stated goals. If no, quickly find reasons and work on that. Find your weak areas and fight them. This sounds funny, but I know a very good developer with strength knowledge, but his coding/typing speed is ugly. Why? Because he has a bad keyboard and don’t want to spend 10-20 hours with a keyboard trainer. Isn’t it stupidity? Men, if you will read this, please promise yourself that you will fight that thing.

8. Do your gym Smile | :)

I did a bit of “brainstorming” when writing this article. And “Do your gym” fell there. I’m quite a young man and spend too much time with my laptop and with another machine at work and I cannot coerce myself for doing gym. But this is just like sharpening the blade. There is story about two woodcutters who made a bet based on count of cut trees. One was Strong man and another was Thin (like me). The Strong one was sure that he will win since he was cutting trees 8 hours without a single break and since Thin one had rest each hour for 15 minutes. But Thin won the battle – he cut 150 per contra 100 of the Strong man. His secret is that he was sharpening the blade. Your health is your axe; if you will keep it blunt, you will not be able to cut down your way.

Uncategorized

My All Time Fav Person Andriy Buday

2016: Where Do You Want to Be In a Year

Some people say that the best way to motivate yourself is to be inspired and/or desperate. At the moment I don’t feel like I’m any of those two. I was very ambitious and inspired in the past, but I guess things change as you get older.

One thing that still helps me a bit with motivation is planning and recognition of my work by others. You can get inspired just by thinking on what you want to do in your life. Also, in my opinion, planning puts you in somewhat desperate situation as you want to complete items from the list. I don’t know if you like planning or not, but I use it for the above reasons and for the reason of keeping track of greater picture of my life goals.

I’ve been writing year resolution posts on my blog since 2010. There are few things that I’ve learned about planning for a year. It is easy to overestimate what can be done and to lose track if no detailed planning was done. So for this year I want to set somewhat smarter goals and do a detailed elaboration on achieving them. I will break down tasks to monthly tasks and keep track of those separately from this blog, as it will be a total mess to post it here.

92-of-all-new-year-resolutions-fail

Let me start my planning with list of life areas to improve.

I want to improve:

  • health by running regularly and doing some gym
  • life satisfaction by travelling and having more quality time with family
  • soft skills by copying the best characteristics of people I admire
  • professional skills by learning one or two technologies and doing a personal project
  • foreign languages proficiency by acquiring German B1 and fixing English accent
  • financials by learning more on investing, keeping expenses low and deciding on home purchase

Now let me convert this list into some concrete achievable and measurable items.

  1. Run 2-3 times a week for at least 5 warm months.
  2. Make start of the day more healthy and productive. Ideal scenario would be: get up at 05:55AM, drink glass of water, do exercises for 15-30 min, shower, some important task and/or planning for the day, breakfast, work… But I will consider this item achieved if I start doing exercises regularly even if it is only 2 times a week just for 10 minutes.
  3. Travel to the UK, Norway, sea side country, and do a car trip somewhere nice.
  4. Spend one hour every day with my daughter playing and learning things.
  5. Count not more than 12 weekends in a year when we didn’t go out to do some activities.
  6. Learn 12 simple skills from other people. To achieve this goal I will first identify 12 people from the community and those surrounding me and chose some characteristic I admire.
  7. Read at least 6 technical books.
  8. Watch at least 12 pluralsight courses.
  9. Write a simple stock analysing web site. It could have any set of features, point is to get something interesting running.
  10. Write any simple useful open source tool. I have WCF related idea in mind.
  11. Learn at least two web technologies. I have NodeJS and AngularJS in mind at the moment.
  12. Share knowledge more actively. Minimum would be to write 24 blog posts, answer 12 questions on SO, help few people online.
  13. Acquire B1 German certificate, attend German course, finish entire German Duolingo tree.
  14. Learn English language prosody and fix pronunciation of vowels. Optionally attend a specialized language course.
  15. Save 24X my monthly spendings, go through 13 investment books I read in 2015 and extract notes, do reviews and write about them.

In the end of this year I don’t want to find myself among those 92% who fail with their new year’s resolutions, therefore keep an eye on me and I promise I will keep an eye on you, provided that you share your list with me.

Happy New Year!

 

this the new activity note of this year…its interesting

http://andriybuday.com/2016/01/2016-where-do-you-want-to-be-in-a-year.html

 

official page of andrybuday

 

 

 

 

 

 

 

Uncategorized

Sql Foreign Key

Foreign Key in SQL

In the lesson about joins, we matched rows from the clients table with rows from the salespersons table.

The clients table contained a column called salesperson_id. We matched this column to the column called id in the salespersons table:

In this example :

  • salesperson_id is the foreign key (key having the value of a column in another table).
  • id of salespersons is the parent key.
  • we call clients the child table or the referencing table.
  • we call salesperson the parent table or the referenced table.
  • A salesperson can take care of one or more clients. Example: the sales person which id equals 1 takes care of clients Aadit Gupta and Aamir Malhotra.
  • There cannot be more than one salesperson taking care of one client (in the column salesperson_id, there cannot be more than one value in one field).

Syntax:

ALTER TABLE clients
ADD FOREIGN KEY (salesperson_id) REFERENCES salespersons(id);

In this statement:

  • clients is the child table. This table contains the column that we use as a foreign key.
  • salesperson_id is the column that we use as a foreign key.
  • id is the column we use as a parent key. It helps performance if this column is also the primary key of the table salespersons.
  • salespersons is the table containing the column that we use as a parent key.

Foreign key is a constraint.

Having a foreign key prevents the following actions:

  • inserting a row in the child table with a value in the foreign key not corresponding to any value in the parent key.
  • deleting a row in the parent table matching at least one row in the child table.

Example:

Cascading on update or a delete to the child table.

You can add a rule that if a parent row is deleted, all corresponding child rows are deleted as well:
To add such a rule, add “ON DELETE CASCADE” at the end of the statement creating the foreign key.

Example:

On table salespersons: if I delete a row in salespersons, then the rows having salespersons_id equal to this salesperson’s id will be deleted.

Uncategorized

JQUERY

Jquery tutorial for beginners with examples

Now i have started learning JQuery so i wanted to have my own concise tutorial article for JQuery. I hope this will be helpful to other beginners too.

Note*: There are other tutorial on web which is quite good, basically JQuery’s own tutorial. If you are looking for more details you can also look for the API document of JQuery.

What is JQuery and What is not

JQuery is open source lightweight Javascript Library which is used to simplify interaction between HTML and JavaScript.

JQuery is not a language. JavaScript is a Language. JQuery is built over JavaScript.

How to use JQuery

You can start using JQuery by adding JQuery library in HTML file.

<!doctype html>
<html>
<head>
<meta charset=“utf-8” />
<title>Demo</title>
</head>
<body>
</body>
</html>

Imp Point in above code

  • Here we are using JQuery.min.js instead of JQuery.js. In Production you should use minified version of library. It will load fast as it doesn’t contain unnecessary comment and whitespaces.
  • JQuery is getting loaded from Google CDN instead of self hosting. It will again make your site load faster. Also it will help you website take advantage of cache.

JQuery Syntax

Now we know how to use JQuery in web page. Next step would be using JQuery syntax. Common syntax for JQuery would be

$(<Where_to_do_Action>).<When_To_Do_Action>(<What_To_Do>);

Example of JQuery Syntax

I want to show an alert message when ever document is ready or loaded completely.

Where(Selectors) : On Document.

When (Action): Document is in ready state or loaded completely.

What(Function) : Show an alert message.

Syntax in JQuery for above requirement

$(document).ready(alert(“Hi”));

Different options for Selector(Where)

All Element – *

Current HTML element – this

Class –   .<Class_Name>   (look for dot)

Id – #<Id_Name> (look for #)

HTML element 

  • a (hyperlink)
  • table
  • tr
  • td
  • p
  • …….

Complete HTML Code

<!doctype html>
<html>
<head>
<meta charset=“utf-8” />
<title>Demo</title>
</head>
<body>
$(document).ready(alert(“Hi”));
</body>
</html>