Linked list in C-Language

Link List:

Link List is a collection of Nodes. Each node consists of a Data field and Address of Next field in the linked list.

Single Linked List consists of Data and Address of next field
Single Linked List consists of Data and Address of next field

Linked is used in case of dynamic memory allocation which avoids the concept of allocating memory to variables at compile time. In this case we can creae nodes at run time, so the memory allocattion will be done at run time.

Linked list can be developed using the user defined data types. i.e Structure

struct list {
int data;
struct list * next;
};

Here in above example list is the name of structure which contains two field data and next. data will contain the data to be entered by user and next field will contain the address of next node in the linked list.  Here next is pointer to structure which will be pointing to object of same type.

The various operations that we can perform on Linked List are:

1.  Create Linked List
2.  Insert a new node into Linked List at any desired position
3.  Delete a node from any desired location in a linked list
4.  Calculating length of a linked list
5.  Copy Linked List to another Linked List
6.  Reverse of a linked List
7.  Concatenation of two Linked Lists
8.  Searching an element in a linked list
9.  Sorting of a Linked List

All these programs are going to be published on this website soon, Linked List users stay tuned with this website, the programs will be written in C-Language.

Bookmark and Share

MVC Architecture

MVC architecture  is basically designed to separate the business logic and application data from the presentation data to manage easily.
MVC stands for L Model – View – Controller

1).  Model: The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed to the browser.

2). View : The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view’s to maintain the consistency in its presentation when the model changes.

3). Controller:  Whenever the user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller is responsible for directing the appropriate view to the user. The views and the controllers work very closely together.

Advantages of using the MVC Architecture.

1. Code developed using MVC is resuable
2. When the problems recurs, there is no need to invent a new solution, we just have to follow the pattern and adapt it as necessary.
3. By using the MVC design pattern our application becomes more expressive.
4. Expaning of an application is very easy as business logic is seperated from UI.
5. Tomorrow if you need to switch the database from, say, SQL to Oracle you dont need to change the whole application, only the Model layer will be changed.


Bookmark and Share

Tips for Creating a better E-Commerce Application

E-Commerce, A name started few years back and now ruling the world. Most of the companies started their E-Commerce portals to sell products online to increase their sales and some are even only online portals they don’t have off line stores and they sell some one else’s products.

Now a days people want the products at their door steps. If your services are on time then no one can beat you in E-Commerce, Following are few of recommendations to develop an E-Commerce Application:

1. A neat and clean website design

Your website UI design must be very clear and soothing that users visit again and again, atleast to review the design.

2. Avoid Ads:

if you want to show some Ads go for internal Ads, Like Ad of one of your product which is going to appear on other page

3. Easy to find Products:

Put a Search box, so that users can easily find the products on website, People don’t remember SKUs so make the search keyword enabled, better to go for Full Text Search.

4.  Better Searched Results Page:

The search results page should be interactive enough to display the maximum products and at the same time the page should not be cluttered enough that irritates the customer to find the required product.

5. Put Drill Down on Searched Results:

The successful websites like Amazon, E-Bay, CNET etc have the Drill Downs impemented on the searched results. Suppose user entered the keyword “Laptop” in the search box, Now it will display the list of all the laptops in the searched results but the true E-Commerce leader will display the searched results as the Groups of Laptops. Grouping by Brand, Grouping By common paratmeters like screen size, RAM, Processor, Next Generation Processors, Price Slabs (500$ – 800$, 1000$ to 1200$) etc so that user’s can easily idetify the product that they required.

6. Product Details Page:

Your  product details page is very important for the user, as its going to behave like a Sales Man, Display the product with Multiple pictures, one picture on the screen of medium size and show some icons of the images below the main image and let the user to view the bigger images. Give all the four views of a product to user for his satisfaction.

Dont write very long descriptions, describe important points and give a summary too.

7. Product Variants:

Display variants of products on Product Detail Pages. When you enter a shop and check a laptop the sales person will also show you the different models of that laptop or different skins available for that so that you can have options to buy. similarily this page is your sales man.

8. Shopping Cart:

Make an interactive shopping cart, easy to operate where the quantity of the prodcuts can be altered.

9. Easy Checkout:

There should be an easy checkout system, Users should be able to enter multiple Shipping addresses while let them have only one billing address and store those shipping and billing addreses for future usage.

10. Payment Gateway Integration:

Always go for Secured and known payment Gateways like paypal, google that people can trust over.

11. Use SSL certificate to make the pages secured:

Its very necessary for you to implement the SSL certificate to prevent fraud and theft of your important information.  Users will not trust your site untill it has the SSL installed – i mean https://

12. Display Secured Logos:

Display the logo of that SSL provider on your website that let the users know that the site is secured. there are various organizations who keep on testing your websites and make sure that your website is hackers safe and fraudulent free. Like Hackerssafe. keep these logos on your website that will assure users that your site is protected and safe which will eventually increase your site traffic.

13. Let the people sell your Products on their sites:

Pubish the XML / CSV feeds. Let people subscribe to that. In this way, your product selling will increase and your brand will be promoted.

14. Google Page Rank:

Google page rank play an important role in E-Commerce Applications, Now a days users are more smart than the programmers. They know the importance of Google Page Rank and they know if a site has high Page rank (atleast PR-4) that means that site has importance in Google eyes and will be Good. Click here to find steps to increase Google Page Rank

15 Alexa Page Rank:

Alexa page rank defines the usage of the site. It shows the rank of a page as per the visits of  the users. so user can some to know how popular is your site is.

These were few steps to make your e-commerce application as the best E-Commerce application.

We at Zonix develop these E-Commerce Application, if you would like to go for that – contact at www.zonixsoft.com or email at [email protected]. Few more things are more which we will be publishing in near future. Keep visiting.

Bigbuyindia is an E-Commerce Portal where you can buy India Jewellery products.


Bookmark and Share

Tips for Creating a better E-Commerce Application

E-Commerce, A name started few years back and now ruling the world. Most of the companies started their E-Commerce portals to sell products online to increase their sales and some are even only online portals they don’t have off line stores and they sell some one else’s products.

Now a days people want the products at their door steps. If your services are on time then no one can beat you in E-Commerce, Following are few of recommendations to develop an E-Commerce Application:

1. A neat and clean website design

Your website UI design must be very clear and soothing that users visit again and again, atleast to review the design.

2. Avoid Ads:

if you want to show some Ads go for internal Ads, Like Ad of one of your product which is going to appear on other page

3. Easy to find Products:

Put a Search box, so that users can easily find the products on website, People don’t remember SKUs so make the search keyword enabled, better to go for Full Text Search.

4.  Better Searched Results Page:

The search results page should be interactive enough to display the maximum products and at the same time the page should not be cluttered enough that irritates the customer to find the required product.

5. Put Drill Down on Searched Results:

The successful websites like Amazon, E-Bay, CNET etc have the Drill Downs impemented on the searched results. Suppose user entered the keyword “Laptop” in the search box, Now it will display the list of all the laptops in the searched results but the true E-Commerce leader will display the searched results as the Groups of Laptops. Grouping by Brand, Grouping By common paratmeters like screen size, RAM, Processor, Next Generation Processors, Price Slabs (500$ – 800$, 1000$ to 1200$) etc so that user’s can easily idetify the product that they required.

6. Product Details Page:

Your  product details page is very important for the user, as its going to behave like a Sales Man, Display the product with Multiple pictures, one picture on the screen of medium size and show some icons of the images below the main image and let the user to view the bigger images. Give all the four views of a product to user for his satisfaction.

Dont write very long descriptions, describe important points and give a summary too.

7. Product Variants:

Display variants of products on Product Detail Pages. When you enter a shop and check a laptop the sales person will also show you the different models of that laptop or different skins available for that so that you can have options to buy. similarily this page is your sales man.

8. Shopping Cart:

Make an interactive shopping cart, easy to operate where the quantity of the prodcuts can be altered.

9. Easy Checkout:

There should be an easy checkout system, Users should be able to enter multiple Shipping addresses while let them have only one billing address and store those shipping and billing addreses for future usage.

10. Payment Gateway Integration:

Always go for Secured and known payment Gateways like paypal, google that people can trust over.

11. Use SSL certificate to make the pages secured:

Its very necessary for you to implement the SSL certificate to prevent fraud and theft of your important information.  Users will not trust your site untill it has the SSL installed – i mean https://

12. Display Secured Logos:

Display the logo of that SSL provider on your website that let the users know that the site is secured. there are various organizations who keep on testing your websites and make sure that your website is hackers safe and fraudulent free. Like Hackerssafe. keep these logos on your website that will assure users that your site is protected and safe which will eventually increase your site traffic.

13. Let the people sell your Products on their sites:

Pubish the XML / CSV feeds. Let people subscribe to that. In this way, your product selling will increase and your brand will be promoted.

14. Google Page Rank:

Google page rank play an important role in E-Commerce Applications, Now a days users are more smart than the programmers. They know the importance of Google Page Rank and they know if a site has high Page rank (atleast PR-4) that means that site has importance in Google eyes and will be Good. Click here to find steps to increase Google Page Rank

15 Alexa Page Rank:

Alexa page rank defines the usage of the site. It shows the rank of a page as per the visits of  the users. so user can some to know how popular is your site is.

These were few steps to make your e-commerce application as the best E-Commerce application.

We at Zonix develop these E-Commerce Application, if you would like to go for that – contact at www.zonixsoft.com or email at [email protected]. Few more things are more which we will be publishing in near future. Keep visiting.

Bigbuyindia is an E-Commerce Portal where you can buy India Jewellery products.


Bookmark and Share

Multiple Active Result Sets (MARS – ADO.NET 2.0)

Multiple Active Result Sets (MARS) is a feature in ADO.NET 2.0. It allows execution of multiple batches against Database on a single connection. Preeviously, only one batch could be executed at a time against a single connection. But, execution of multiple batches with MARS does not mean like simultaneous execution of operations.
In previous versions of SQL Server; to access multiple result sets using SqlDataReader objects, a separate SqlConnection object must be used with each SqlCommand object. In ADO.NET 2.0 / SQL Server 2005; MARS feature is disabled by default. It can be enabled by adding the “MultipleActiveResultSets=True” keyword pair to your connection string, as below:

string connectionString = @”Data Source=GTL-263SQLEXPRESS;Initial Catalog=master;Integrated Security=SSPI;MultipleActiveResultSets=True“;

Example:

Without MARS, you could only run one batch per connection. some what like below Example:

private void NoMarsImplementation()
{
SqlConnection conn = new SqlConnection(@”Data Source=GTL-263SQLEXPRESS;
Initial Catalog=master;Integrated Security=SSPI;”);

string sql1 = “SELECT * FROM [Customer].[TBL_Customer]”;
string sql2 = “SELECT * FROM [Supplier].[TBL_Supplier]”;

SqlCommand cmd1 = new SqlCommand(sql1, conn);
SqlCommand cmd2 = new SqlCommand(sql2, conn);
cmd1.CommandTimeout = 500;
cmd2.CommandTimeout = 500;
conn.Open();
SqlDataReader dr1 = cmd1.ExecuteReader();
// misc. code with dr1
conn.Close();

conn.Open();
SqlDataReader dr2 = cmd2.ExecuteReader();
// misc. code with dr2
conn.Close();
}

Above Example shows that you can use the same connection with the second SqlDataReader only when you finished using the connection with first one. The connection must be closed and reopened to use same Connection with Second SqlDataReader. Otherwise you would get this error – “There is already an open DataReader associated with this Command which must be closed first”.

with MARS, it is possible to use a single opened connection for more than one batch. Check out below code:

private void MarsImplementation()
{
SqlConnection conn = new SqlConnection(@”Data Source=GTL-263SQLEXPRESS;
Initial Catalog=master;Integrated Security=SSPI;MultipleActiveResultSets=true;“);

string sql1 = “SELECT * FROM [Customer].[TBL_Customer]”;
string sql2 = “SELECT * FROM [Supplier].[TBL_Supplier]”;

SqlCommand cmd1 = new SqlCommand(sql1, conn);
SqlCommand cmd2 = new SqlCommand(sql2, conn);
cmd1.CommandTimeout = 500;
cmd2.CommandTimeout = 500;
conn.Open();
SqlDataReader dr1 = cmd1.ExecuteReader();
// misc. code with dr1
SqlDataReader dr2 = cmd2.ExecuteReader();
// misc. code with dr2
conn.Close();
}

In this way, using MARS, you can simply execute an SqlDataReader that will open a Read-Only Cursor; use data from that SqlDataReader and perform Insert / Update function against Database. You only need to Open the SqlConnection object once before you execure the SqlDataReader and Close the Connection (without re-openning) at last after performing Insert / Update function.

Here is another Example, in which we retrieve records from Category Table which is having ParentCategoryID as 0 thru SqlDataReader and Update the Product Table records which is having CategoryID from SqlDataReader.

private void MarsImplementation()
{
//connection string
string connectionString = @”Data Source=GTL-263SQLEXPRESS;Initial Catalog=master;
Integrated Security=SSPI;MultipleActiveResultSets=true;“;

SqlTransaction updateTran = null;
//sqlCommand to open SqlDataReader
SqlCommand catCmd = null;
//sqlCommand to update the Product table
SqlCommand updateCmd = null;

int CategoryID = 0;

//Query to fetch the categories with ParentCategoryID having 0
string catSQL =
“SELECT CategoryID, Name FROM Category ” +
“WHERE ParentCategoryID = 0”;

//update all the product’s quantity which is having CategoryID from above Query
string updateSQL =
“UPDATE Product ” +
“SET Qty = Qty + @OrderQty ” +
“WHERE CategoryID = @CategoryID”;

using (SqlConnection Connection =
new SqlConnection(connectionString))
{
Connection.Open(); //open the connection once here
updateTran = Connection.BeginTransaction();

catCmd = new SqlCommand(catSQL, Connection);
catCmd.Transaction = updateTran;

updateCmd = new SqlCommand(updateSQL, Connection);
updateCmd.Transaction = updateTran;
updateCmd.Parameters.Add(“@Qty”, SqlDbType.Int);
updateCmd.Parameters.Add(“@ProductID”, SqlDbType.Int);

//execute the sqlDataReader
using (SqlDataReader catReader = catCmd.ExecuteReader())
{
while (catReader.Read())
{
CategoryID = (int)catReader[“CategoryID”];

updateCmd.Parameters[“@OrderQty”].Value = 100;
updateCmd.Parameters[“@CategoryID”].Value = CategoryID;
//perform Update against Product table with same connection
//without closing and re-openning it again
//having SqlDataReader already openned
updateCmd.ExecuteNonQuery();
}
}
updateTran.Commit();
}

}


Bookmark and Share

Move a SharePoint Content Database / Deploy sharepoint site

our Official website (https://zonixsoft.com)

You have two initial options, doing a backup and restore within MOSS to move the data, or doing it at the SQL/STSADM level.  I prefer the latter, as it isn’t nearly as inclined to fail and leaves you with more flexibility.

1) Find the content Database

These are listed under Central Admin->Application Management->Site Collection List

2) Backup the content database

You could alternatively detach it, and copy it.  Just doing a backup in SQL Server 2005 Management studio is easier.

3) Restore content database to new server

Copy the BAK file to new server.  Create an empty DB in Management Studio, restore from backup, you may need to change an option in the “options” tab of the restore dialog to get it to work.  (Overwrite db).

4) Create Web App on new Server

Central Admin->Application Management->Create or extend Web App->Create New Web App.

5) Associate restored DB with new Web App

Central Admin->Application Management->

SharePoint Web Application Management->Content Databases->

Remove Content Database from your new web app.

Now use STSADM to add restored DB to this web app

c:program filescommon filesmicrosoft sharedweb server extentions12bin on new server is where you can find the STSADM.

run this command from there.

stsadm -o addcontentdb -url http://yourwebapp:port -databasename yourcontentdb -databaseserver yoursqlserver

6) Run ISSRESET from command prompt.


Bookmark and Share

How Big is google’s database

Visist : https://zonixsoft.com (Our Official Website)

Google search crawler uses 850 TB of information, so that’s the amount of raw data from the web.

Google Analytics uses 220 TB stored in two tables: 200 TB for the raw data and 20 TB for the summaries.

Google Earth uses 70.5 TB: 70 TB for the raw imagery and 500 GB for the index data.

The second table “is relatively small (500 GB), but it must serve tens of thousands of queries per second per datacenter with low latency”.

Personalized Search doesn’t need too much data: only 4 TB.
Personalized Search stores each user’s data in Big table.
Each user has a unique user id and is assigned a row named by that user id.
All user actions are stored in a table.

Google Base uses 2 TB and Orkut only 9 TB of data.
If we take into account that all this information is compressed. For example, the crawled data has compression rate of 11%, so 800 TB become 88 TB, Google uses for all the services mentioned before 220 TB.

It’s also interesting to note that the size of the raw imagery from Google Earth is almost equal to the size of the compressed web pages crawled by Google.


Bookmark and Share

The real difference between SQL Server and Oracle

Visit : https://zonixsoft.com (our Official website)

For years now there’s been a constant war between Microsoft supporters and Oracle supporters. Oracle has these features, SQL Server has these features, etc. But that’s not really where the real importance lies. Sure, functionality is a part of it because your database should be able to do what you need it to do. However, do you want to know what the real difference between the two companies is and why Microsoft has made such a strong impact in the industry?…. Read More….


Bookmark and Share

UPDATE Based Off of A Table

visit : https://zonixsoft.com (our official website)

 INSERT offers the ability to insert into a table based upon a SELECT statement with the following syntax:

INSERT INTO [TABLEA] ([FIELDA],[FIELDB],[FIELDC])
        SELECT [FIELDA],[FIELDB],[FIELDC]
FROM [TABLEB]

 

there are time where you may want to do a similar approach with UPDATE.
Here is the syntax to do that very task:

UPDATE [TABLEA]
        SET  [TABLEA].[FIELDA] = [TABLEB].[FIELDA] 
               [TABLEA].[FIELDB] = [TABLEB].[FIELDB] 
               [TABLEA].[FIELDC] = [TABLEB].[FIELDC] 
        FROM [TABLEA]
               JOIN [TABLEB]
        ON [TABLEA].[KEYA] = [TABLEB].[KEYA]

 


Bookmark and Share

Passing parameters to dynamic query

visit https://zonixsoft.com (our official Website)

 

Consider following queries

1. SELECT * FROM @tablename

2. SELECT @colname FROM tbl

3. SELECT * FROM tbl WHERE x IN (@list)

4. SELECT @Cnt=Count(*) FROM tbl WHERE x IN (@list)

 

For the first query, it will give error ‘Must declare the table variable “@tablename”‘ if @tablename is not Table variable.

For Second query it will display all rows with same value contained in @colname rows in ‘tbl’.

For Third query it will display correct result if @listonly one value(no comma separated values).

Fourth one is same as third query but it stores value in a variable @Cnt. The actual problem will come to know after solving third one.

To get correct result, we need to create Dynamic query for all four queries.

 

The first three queries can be execute correctly by using Exec().

EXEC() takes one parameter which is an SQL statement to execute.The parameter can be a concatenation of string variables and string literals, but cannot include calls to functions or other operators.

 

The first three can be written as:

 

1. Exec (‘SELECT * FROM’ + @tablename)

2. Exec (‘SELECT ‘ + @colname +‘ FROM tbl’)

3. Exec (‘SELECT * FROM tbl WHERE x IN (‘+@list+‘)’)

 

But Fourth one can not be written simply using Exec(). Because if @Cnt is declared outside the statement being executed in Exec() like

 

Declare @Cnt int

Exec(‘SELECT @Cnt = Count(*) FROM tbl WHERE x IN (‘+@list+‘)’)

Select @Cnt

 

it will give error

Must declare the scalar variable “@Cnt”.

 

Here is need of sp_executesql instead of Exec().

sp_executesql is a system stored procedure that you can use in place of “exec” to execute your dynamic sql. It takes two pre-defined parameters and any number of user-defined parameters.

This allows you to have parameters in your dynamic query and pass them in. The end result is that SQL Server will try to cache the execution plan for your query giving you some of the advantages of a fully compiled query.

The first parameter @sql is mandatory, and contains a batch of one or more SQL statements. The data type of @sql is ntext in SQL 7 and SQL 2000, and nvarchar(MAX) in SQL 2005. A varchar value won’t do.

The second parameter @params is optional, but you will use it 90% of the time. @params declares the parameters that you refer to in @sql. The syntax of @params is exactly the same as for the parameter list of a stored procedure. The parameters can have default values and they can have the OUTPUT marker.Just like @sql, the data type of @params in SQL 7/2000 is ntext and nvarchar(MAX) in SQL 2005.

The rest of the parameters are simply the parameters that you declared in @params, and you pass them as you pass parameters to a stored procedure, either positional or named. To get a value back from your output parameter, you must specify OUTPUT with the parameter, just like when you call a stored procedure.

 

Let’s write the fourth query using sp_executesql.

Declare @CntRow int

Declare @sql nvarchar(200)

Declare @params nvarchar(200)

set @sql = ‘SELECT @Cnt=Count(*) FROM tbl WHERE x IN (@list)’

set @params = ‘@list varchar(100),@Cnt int output’

exec sp_executesql @sql,@params,‘1,2,3’,@CntRow output

Select @ CntRow

‘1,2,3’ will be passed to @list and result of @Cnt will be set to @CntRow.


Bookmark and Share