GOOD BYE Letter
Dear All,
Its time to say goodbye to all of you from this blog side. From now i will be available at www.crea8ivecode.net. Thanks to www.wordpress.com for their great support for giving such a wonderful blogging site. As well as thanks to all my well wishers, who inspired me about my blog site.
Once again GOOD BYE.
Thanks
Sadeque Sharif
Filed under: Personal | Leave a Comment
Today when i am trying to insert some data from text file to database table with BULK INSERT. I was facing a problem that trigger attached with the specified table is not firing on insert. In that time i was using the following code:
1: Create procedure [dbo].[prcExtractTextData]
2: as
3: BULK INSERT MachineData
4: FROM 'c:\Data.txt'
5: WITH
6: (
7: FIELDTERMINATOR =':',
8: ROWTERMINATOR ='\n'
9: )
But when i am inserting data through insert statement it works. In that time i realize that there have some problems in BULK INSERT. Immediately i open MSDN and read the BULK INSERT (Transact-SQL). There i found that “FIRE_TRIGGERS” argument which is speciallly used for firing insert triggers. If FIRE_TRIGGERS is not specified, no insert triggers execute. Then i change some code in procedure and it works. That code is given below:
1: Create procedure [dbo].[prcExtractTextData]
2: as
3: BULK INSERT MachineData
4: FROM 'c:\Data.log'
5: WITH
6: (
7: FIRE_TRIGGERS,
8: FIELDTERMINATOR =':',
9: ROWTERMINATOR ='\n'
10: )
Filed under: CodeProject, MS SQL SERVER | Leave a Comment
Tags: BULK INSERT, FIRE_TRIGGERS
We write SQL queries manually in query window. Most of the time it’s hard to remember all the objects name and syntax. As a result it’s takes time to writes statement correctly. We can easily create the SQL query by using QUERY DESIGNER.
To create the new query, do the following steps:
1. Open query window.
2. Go to query menu and click on Design Query in Editor… or press Ctrl+Shift+Q. A Query Designer window will open as like following image.
3. Now create your required query from Query Designer. When complete click OK. See Query that you created from Query Designer will paste into query window.
To change the existing query, do the following steps:
(Existing query’s syntax should be correct. Otherwise it will give error.)
1. Select the whole query from query window.
2. Go to query menu and click on Design Query in Editor… or press Ctrl+Shift+Q. A Query Designer window will open.
3. Now create your required query from Query Designer. When complete click OK. See Query that you create from Query Designer will overwrites the existing query into query window.
Filed under: CodeProject, MS SQL SERVER | Leave a Comment
Tags: Query Designer, Query Designer in SQL server 2005, Query in SQL server 2005
You can easily debug JavaScript from ASP.NET. Just do the following things:
01. Open Internet Explorer.
02. Select Internet Options from Tools menu.
03. Click on Advanced tab.
04. Uncheck the disable script debugging (Internet Explorer) and Uncheck the disable script debugging (Other).
Now debug the JavaScript code from ASP.NET.
Filed under: ASP.NET, CodeProject | 2 Comments
Tags: Debug Javascript in ASP.NET, Javascript Debug
Normally we can add JavaScript event attributes declaratively to the control tag, Like:
1: <asp:TextBox id="TextBox1" runat="server"
2: onmouseover="alert('Your mouse is hovering on TextBox1.');" />
We can do the same same thing by writing the following code in ASP.NET code behind file.
1: protected void Page_Load(object sender, EventArgs e)
2: {
3: TextBox1.Attributes.Add("onmouseover", "alert('Your mouse is hovering on TextBox1.');");
4: }
Filed under: ASP.NET, C#, CodeProject | Leave a Comment
Tags: Attributes, JavaScript event attributes in ASP.NET, JavaScript in ASP.NET
Use FusionCharts In ASP.NET
FusionCharts Free is a FREE flash charting component that can be used to render data-driven animated charts. Made in Macromedia Flash MX, FusionCharts can be used with any web scripting language like PHP, ASP, .NET, JSP, ColdFusion, JavaScript, Ruby on Rails etc., to deliver interactive and powerful charts. Using XML as its data interface, FusionCharts makes full use of fluid beauty of Flash to create compact, interactive and visually-arresting charts. FusionCharts Free edition is available at www.fusioncharts.com/free.
To develop FusionCharts in asp.net you must have some files, which you can get after download the free edition of FusionCharts. Those files are: FusionCharts.dll, FusionCharts.js, & chart file (swf). After collecting all those file you are ready to develop the FusionCharts in asp.net. Now follow the following steps:
Step 1: Create a new project as FusionChart in Visual Studio 2008.
Step 2: Now you have to place those files (FusionCharts.dll, FusionCharts.js, & chart file (swf)) in appropriate place. Otherwise FusionCharts will not work properly. Add the FusionCharts.dll as reference. Create a folder name FusionCharts in project. Then place the FusionCharts.js, & chart file (FCF_Pie3D.swf) into that folder. Now the folder arrangement looks like the image below:
Step 3: Data which I am going to show through FusionCharts is from Northwind Database (MS SQL Server). So now it’s better to do the database related things. I just create a view name CategoryWiseOrder in northwind database. Code for the view is given below:
1: CREATE VIEW [CategoryWiseOrder]
2: AS
3: SELECT Categories.CategoryName, SUM([Order Details].Quantity) AS Quantity
4: FROM Categories
5: INNER JOIN Products ON Categories.CategoryID = Products.CategoryID
6: INNER JOIN [Order Details] ON Products.ProductID = [Order Details].ProductID
7: GROUP BY Categories.CategoryName
Step 4: Copy the following code in web.config file:
1: <connectionStrings>
2: <add name="Northwind" connectionString="Data Source=localhost;Integrated Security=SSPI;
3: Initial Catalog=Northwind;" providerName="System.Data.SqlClient"/>
4: </connectionStrings>
Step 5: add the reference of FusionCharts.js file in Head tag of default.aspx page. Code is given below
1: <script type="text/javascript" language="javascript"
2: src="/FusionCharts/FusionCharts.js"></script>
And add the following code in Body tag of default.aspx page.
1: <%=CreateChart()%>
Now the default.aspx file’s code will be look like following code:
1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FusionChart._Default" %>
2:
3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4:
5: <html xmlns="http://www.w3.org/1999/xhtml" >
6: <head runat="server">
7: <title>FusionCharts In ASP.NET</title>
8: <script type="text/javascript" language="javascript" src="/FusionCharts/FusionCharts.js"></script>
9: </head>
10: <body>
11: <form id="form1" runat="server">
12: <div>
13: <%1: =CreateChart()%>
14: </div>
15: </form>
16: </body>
17: </html>
Step 6: Now go to the code behind file of default.aspx page. Include the following code into code behind file:
1: using InfoSoftGlobal;
1: public string CreateChart()
2: {
3: string ConnectionString = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
4: SqlConnection con = new SqlConnection(ConnectionString);
5: string sqlStatement = "SELECT CategoryName,Quantity FROM CategoryWiseOrder";
6: SqlCommand cmd = new SqlCommand(sqlStatement, con);
7: con.Open();
8: SqlDataReader reader = cmd.ExecuteReader();
9: string strXML;
10: strXML = "<graph caption='Category Wise Quantity' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>";
11: while (reader.Read())
12: {
13: strXML += "<set name='" + reader["CategoryName"].ToString() + "' value='" + reader["Quantity"].ToString() + "' />";
14: }
15: strXML += "</graph>";
16: return FusionCharts.RenderChart("/FusionCharts/FCF_Pie3D.swf", "", strXML, "FactorySum", "650", "450", false, false);
17: }
Then the default.aspx.cs file will be look like following code:
1: using System;
2: using System.Collections;
3: using System.Configuration;
4: using System.Data;
5: using System.Linq;
6: using System.Web;
7: using System.Web.Security;
8: using System.Web.UI;
9: using System.Web.UI.HtmlControls;
10: using System.Web.UI.WebControls;
11: using System.Web.UI.WebControls.WebParts;
12: using System.Xml.Linq;
13: using System.Data.SqlClient;
14: using InfoSoftGlobal;
15:
16: namespace FusionChart
17: {
18: public partial class _Default : System.Web.UI.Page
19: {
20: protected void Page_Load(object sender, EventArgs e)
21: {
22: }
23: public string CreateChart()
24: {
25: string ConnectionString = ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString;
26: SqlConnection con = new SqlConnection(ConnectionString);
27: string sqlStatement = "SELECT CategoryName,Quantity FROM CategoryWiseOrder";
28: SqlCommand cmd = new SqlCommand(sqlStatement, con);
29: con.Open();
30: SqlDataReader reader = cmd.ExecuteReader();
31: string strXML;
32: strXML = "<graph caption='Category Wise Quantity' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>";
33: while (reader.Read())
34: {
35: strXML += "<set name='" + reader["CategoryName"].ToString() + "' value='" + reader["Quantity"].ToString() + "' />";
36: }
37: strXML += "</graph>";
38: return FusionCharts.RenderChart("/FusionCharts/FCF_Pie3D.swf", "", strXML, "FactorySum", "650", "450", false, false);
39: }
40: }
41: }
That’s all. Run the project and see how its looks. It will look like the following image:
If you want the project, just send me a mail at sadeque.sharif@yahoo.com
Filed under: ASP.NET, C#, Third Party Tools | 8 Comments
Tags: ASP.NET FusionCharts, FusionCharts, FusionCharts In ASP.NET, FusionCharts in C#, FusionCharts in Visual Studio
The SQL Server 2005 Database Engine automatically maintains indexes whenever insert, update, or delete operations are made to the underlying data. Over time these modifications can cause the information in the index to become scattered in the database (fragmented). Fragmentation exists when indexes have pages in which the logical ordering, based on the key value, does not match the physical ordering inside the data file. Heavily fragmented indexes can degrade query performance and cause your application to respond slowly. For more information, see this Microsoft Web site.
In SQL Server 2005 you can remedy index fragmentation by either reorganizing an index or by rebuilding an index.
A. Rebuilding an index
The following example rebuilds a single index.
USE AdventureWorks;
GO
ALTER INDEX PK_Employee_EmployeeID ON HumanResources.Employee
REBUILD;
GO
B. Rebuilding all indexes on a table and specifying options
The following example specifies the keyword ALL. This rebuilds all indexes associated with the table. Three options are specified.
USE AdventureWorks;
GO
ALTER INDEX ALL ON Production.Product
REBUILD WITH (FILLFACTOR = 80, SORT_IN_TEMPDB = ON,
STATISTICS_NORECOMPUTE = ON);
GO
C. Reorganizing an index with LOB Compaction
The following example reorganizes a single clustered index. Because the index contains a LOB data type in the leaf level, the statement also compacts all pages that contain the large object data. Note that you do not have to specify the WITH (LOB_Compaction) option because the default value is ON.
USE AdventureWorks; GO ALTER INDEX PK_ProductPhoto_ProductPhotoID ON Production.ProductPhoto REORGANIZE ; GO
Filed under: MS SQL SERVER | 3 Comments
Tags: Indexing in MS SQL, MS SQL performance, SQL database performance, SQL performance
Use GUID in MS SQL and Oracle
you can use GUID in MS SQL and Oracle.
For MS SQL use the following code:
select newid()
For Oracle use the following code:
select sys_guid() from dual
To know more about GUID go to http://en.wikipedia.org/wiki/Globally_Unique_Identifier
Filed under: CodeProject, MS SQL SERVER, Oracle | Leave a Comment
Tags: guid in mssql, guid in oracle
Most of the times it’s hard to do everything in one application at oracle. Though oracle enterprise manager is available from version 9. it’s not so simple. But Toad For Oracle Xpert comes out with a great facility for oracle developers. You can do most of things in here.
Toad for Oracle Xpert includes all of the features in Toad for Oracle Professional, plus integrated SQL performance tuning through SQL Optimizer’s SQL Scanner. This utility automatically identifies the SQL statements that may perform poorly in production. It then rewrites SQL for you and offers alternate implementations to improve performance.
Toad for Oracle Xpert can also generate virtual indexes and provide advice on the impact of changes to improve the performance of a set of SQL statements.
You can download it from http://www.toadworld.com
Filed under: Oracle, Software | Leave a Comment
Tags: Toad, Toad for Oracle
I start my career as a software developer from a software firm. After that I join in a garment manufacturing industry & still doing the same thing (software development). From my last 4 years experience I heard the same thing from most of the non IT people that, IT people don’t do anything. Sometimes I think that, is it true? Why they think like this?
I ask some of them why IT people don’t do anything. They give me few comments. Now I put some of those comments for all the IT people.
- IT people sit whole day in front of PC & think. Ultimately they do nothing.
- Whatever they do, its so simple. Everybody can do it.
- Whatever they do its not measurable. Actually they do nothing.
- Their contribution for the company is too low.
- They don’t do any hard work.
- Companies wasting money against IT people.
- We run the system very well, when they are not in here.
- Whatever things they develop, is it require?
what’s your opinion about it?
Filed under: General | 4 Comments
Recent Entries
- GOOD BYE Letter
- what FIRE_TRIGGERS argument do in BULK INSERT ?
- Quickly create SQL query in SQL server 2005 with query designer
- Debug JavaScript from Visual Studio 2008
- Add JavaScript code programmatically in ASP.NET code behind file
- Use FusionCharts In ASP.NET
- How to optimize database performance in MSSQL through reorganizing and rebuilding indexes
- Use GUID in MS SQL and Oracle
- Toad For Oracle Xpert (Version 9.5.0.31) – great tool for oracle developers
- Non IT people think that IT people don’t do anything !!!
- How to improve MS SQL database performance
Categories
- ASP.NET (3)
- C# (2)
- CodeProject (6)
- General (1)
- MS SQL SERVER (5)
- Oracle (2)
- Personal (1)
- Software (1)
- Third Party Tools (1)
- Visual Basic 6 (1)