<?xml version="1.0" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">

	<channel>
		<lastBuildDate>Fri, 04 Aug 2006 09:56:08 GMT</lastBuildDate>
		<copyright>All content &amp;copy; Vishal Monpara</copyright>
		<description>This site sheds light on different technology</description>
		<link>http://article.vishalon.net</link>
		<title>article@vishalon.net</title>
		<language>en-US</language>
		<item>
			<title>Why do we need DTS (Data Transformation Service?)</title>
			<description>&lt;P&gt;Lets say you have data in one format(It can be a database/file/excel spreadsheet also). You want to convert it into another format. You will have a thought of writing a VB program and convert the source file into the format of destination file. But wait a minute. If you have lots of files in the different format and you want to convert it into different formats, then would you write VB programs for each conversion? You can write, but it is very time consuming and error prone. &lt;/P&gt;
&lt;P&gt;Here comes into picture the DTS. As name suggests, it is a service for transforming data from one format to another. We can draw a workflow diagram of the data and SQL server Enterprise Manager will automatically create code to execute it. Here we need not have knowledge of how to open a file in VB, how to manipulate data, and how to store in the destination. DTS package handles all these intricacies automatically. Suppose you have excel file in which user data is stored. Now you want to put only certain data (for ex. all persons whose email address ends with yahoo.com) to SQL Server. In DTS, you have to drag excel sheet object, SQL Server object and make them point to appropriate source and destination. Put an arrow pointing from excel sheet to SQL Server. An arrow represents transformation of data from one form to another. By default, it transforms all data. We can create a custom tranformation and depending on the condition, we can insert data into SQL Server.&lt;/P&gt;
&lt;P&gt;So the ease with DTS is, if we have multiple transformation, it would be very easy for a programmer to transform data from one form to another without lots of coding.&lt;/P&gt;
&lt;P&gt;So lets start using DTS with a simple example. You have excel file and you want to upload it in SQL Server. So here are the steps.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Enterprise Manager &amp;gt; Microsoft SQL Servers &amp;gt; [SQL Server Group] &amp;gt; [SQL Server] &amp;gt; DAta Transformation Services &amp;gt; Local Packages. 
&lt;LI&gt;Right click on it and choose "New Package" 
&lt;LI&gt;On the left hand side, you can see "Connection" and "Task". Connection represents source and destination of data. Task represents different tasks to convert the data from one form to another 
&lt;LI&gt;In "Connection" 3rd button is Excel. Click on it. It will open a dialog box. Provide the name of the new connection and browse the source excel file and put the path in "File Name". 
&lt;LI&gt;In "Connection" 1st icon represents SQL Server. Click on it and provide valid credentials and select appropriate database. 
&lt;LI&gt;In "Task" menu 3rd button is "Transform Data Task". Now click on Excel icon which will become source. Click on SQL Server icon. It will become destination. 
&lt;LI&gt;Double click on the arrow. It will open up property which is important to transform Excel data into SQL data. 
&lt;LI&gt;Select appropriate sheet in Source tab. In Destination tab, select appropriate table name. For our case it is "Item". 
&lt;LI&gt;You can see one to one mapping from source field to destination fields. Now press "OK". 
&lt;LI&gt;In the main menu, go to "Package" &amp;gt; Execute. This command starts executing the package. Now if you open the table, you will see the data.&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;You can download the whole dts package by clicking on &lt;A HREF="/Download/DTSExample.zip"&gt;DTS Package Example&lt;/A&gt;. Please save the package in c:\. From enterprise manager, right click on "Data Transformation Services" and choose "Open Package", browset c:\DTS\DTSExample.dts. Once you open it, double click on SQL Server icon and change the credentials. Run the script &lt;BR&gt;DTS.sql to create a table "Item".&lt;/P&gt;</description>
			<link>http://article.vishalon.net/Post/79.aspx</link>
			<dc:creator>Vishal Monpara</dc:creator>
			<pubDate>Fri, 04 Aug 2006 16:56:08 GMT</pubDate>
			<guid>http://article.vishalon.net/Post/79.aspx</guid>
		</item>
		<item>
			<title>Things to remember while converting Microsoft Access application into SQL Server application</title>
			<description>
		&lt;p&gt;When the Access database grows much large and the performance of the application gets worsen, you might need to think of upsizing the Access database into SQL Server database. So that you can split your MS Access front end and SQL Server back end. Microsoft Access comes with a utility called "Upsizing Wizard". It is located at Tools &amp;gt; Database Utility &amp;gt; Upsizing Wizard. This utility tries its best to convert the whole database including data tables, queries, relationships etc. This wizard is able to convert all tables perfectly but it might convert all queries into stored procedures or functions or views. &lt;/p&gt;
		&lt;p&gt;Choose the solution between Access application with Linked tables or Access Data Project.&lt;/p&gt;
		&lt;p&gt;When you are linking a table from a database on the network, the datasource is not updateable. So if the application adds/updates/deletes record, then this solution is not for you. Access Data Project is the best solution for the application which needs updateable recordset. One can import different objects like forms/reports in Access Data Project. Here the tables are not linked but you can direclty manipulate the database.&lt;/p&gt;
		&lt;p&gt;How to convert query into stored procedure?&lt;/p&gt;
		&lt;p&gt;When the query is directly used in a form which is using/not using a form variable, convert it into stored procedure.&lt;br /&gt;Ex. The query is select * from EMP where Name like [forms]![Emp Form]![Name]&lt;br /&gt;Create Procedure GetEmployee&lt;br /&gt;(&lt;br /&gt;    @Name nvarchar(20)&lt;br /&gt;)&lt;br /&gt;AS&lt;br /&gt;    Select * from EMP where Name like @Name&lt;/p&gt;
		&lt;p&gt;If the query is using another query without any variable, make the first query as a stored procedure and convert second query into view.&lt;/p&gt;
		&lt;p&gt;If the query is using another query with variable, make the first query as stored procedure with variable and convert second query into a function.&lt;br /&gt;Now you can use this function result as a temporary table.&lt;/p&gt;
		&lt;p&gt;Use Pass-through query wherever possible, because it reduces network traffic.&lt;/p&gt; and last but not least&lt;p&gt;&lt;b&gt;PAY ATTENTION TO THE BOOLEAN COMPARISION AND NULL VALUE CONCATENATION&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Once you upsize the database, MS wizard gives you report of how many tables successfully upsized and how it changed the datatypes of columns. Most of the time, it upsizes it correctly but sometimes it just skips some tables/records. So to check it I have created an Access form which can be run to check the consistency of the records. Open the main form "frmMain" give the appropriate value and press "Check..." button. It will store the results in database. Now you can check the results by viewing the queries.&lt;/p&gt;</description>
			<link>http://article.vishalon.net/Post/74.aspx</link>
			<dc:creator>Vishal Monpara</dc:creator>
			<pubDate>Wed, 10 May 2006 06:20:47 GMT</pubDate>
			<guid>http://article.vishalon.net/Post/74.aspx</guid>
		</item>
		<item>
			<title>Subtract Time in Infopath</title>
			<description>
		&lt;p&gt;Infopath is a great tool for rapidly developing an application which
gathers information from the user. Many times these applications uses
start time and end time as their fields. Infopath has a "Time"
datatype. We can directly assign this datatype to the fields. You can
compare two fields of this datatype but substraction of fields is not
handled. You have to manually parse the field value, subtract the
values and change the appropriate fields. Here is the proposed solution
of this problem.
&lt;/p&gt;
This solution contains 3 functions
&lt;br /&gt;&lt;ol&gt;&lt;li&gt;UpdateHours()&lt;/li&gt;&lt;li&gt;convertJScriptNumberToXML()&lt;/li&gt;&lt;li&gt;roundFloat()&lt;/li&gt;&lt;/ol&gt;
Lets see all these functions one by one.
&lt;pre&gt;function UpdateHours()&lt;br /&gt;{&lt;br /&gt;	var TimeIn = XDocument.DOM.selectSingleNode("/my:Time/my:StartTime").text;&lt;br /&gt;	var TimeOut = XDocument.DOM.selectSingleNode("/my:Time/my:EndTime").text;&lt;br /&gt;	var index1 = TimeIn.indexOf(":");&lt;br /&gt;	var hi = TimeIn.substring(0,index1);&lt;br /&gt;	var index2 = TimeIn.indexOf(":", index1+1);&lt;br /&gt;	var mi = TimeIn.substring(index1+1, index2);&lt;br /&gt;	index1 = TimeOut.indexOf(":");&lt;br /&gt;	var ho = TimeOut.substring(0,index1);&lt;br /&gt;	index2 = TimeOut.indexOf(":", index1+1);&lt;br /&gt;	var mo = TimeOut.substring(index1+1, index2);&lt;br /&gt;	var ti = parseFloat(hi) + (mi/60);&lt;br /&gt;	var to = parseFloat(ho) + (mo/60);&lt;br /&gt;	var tt = to - ti;&lt;br /&gt;	var node = XDocument.DOM.selectSingleNode("/my:Time/my:TotalHours");&lt;br /&gt;	if (tt != "" &amp;amp;&amp;amp; node.getAttribute("xsi:nil"))&lt;br /&gt;		node.removeAttribute("xsi:nil");&lt;br /&gt;	node.nodeTypedValue = convertJScriptNumberToXML(tt);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;As
the name suggests, this function updates the value of "TotalHours"
field. First of all, it will get the value of "StartTime" and "EndTime"
field. The value will be in the format of HH:MM:SS. So the value will
be parsed according to the position of ":". Both the values will be
converted inot the float representation. Now value will be sutracted
and the result will be stored in "TotalHours" field.
&lt;pre&gt;function convertJScriptNumberToXML(value)&lt;br /&gt;{&lt;br /&gt;	var retVal;&lt;br /&gt;	switch (value)&lt;br /&gt;	{&lt;br /&gt;		case Number.NEGATIVE_INFINITY:&lt;br /&gt;			retVal = "-INF";&lt;br /&gt;			break;&lt;br /&gt;		case Number.POSITIVE_INFINITY:&lt;br /&gt;			retVal = "INF";&lt;br /&gt;			break;&lt;br /&gt;		case value:&lt;br /&gt;			retVal = roundFloat(value,2);&lt;br /&gt;			break;&lt;br /&gt;		default:&lt;br /&gt;			retVal = "NaN";&lt;br /&gt;	}&lt;br /&gt;	return retVal;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;
This function converts the actual number into text based value. Here he number will be rounded upto 2 digits.
&lt;pre&gt;function roundFloat(value, decimalPlaces)&lt;br /&gt;{&lt;br /&gt;	if (value &amp;lt; -1E15 || 1E15 &amp;lt; value)&lt;br /&gt;	{&lt;br /&gt;		return value;&lt;br /&gt;	}&lt;br /&gt;	else&lt;br /&gt;	{&lt;br /&gt;		var nPowerToRound = Math.pow(10, decimalPlaces);&lt;br /&gt;		return Math.round(value*nPowerToRound)/nPowerToRound;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;This
function actually rounds the float value to the required decimal place.
To apply this code to your application, copy/paste these three
functions into the script file. In the "OnAfterChange" event of start
time and end time field, call the function "UpdateHours".&lt;br /&gt;&lt;br /&gt;
Note: Please put the downloaded code in C:\ &lt;br /&gt;</description>
			<link>http://article.vishalon.net/Post/59.aspx</link>
			<dc:creator>Vishal Monpara</dc:creator>
			<pubDate>Sat, 14 Jan 2006 05:21:21 GMT</pubDate>
			<guid>http://article.vishalon.net/Post/59.aspx</guid>
		</item>
		<item>
			<title>Utility for rendering HTMLTable control containing ASP .Net form elements into string</title>
			<description>
		&lt;h3&gt;Introduction&lt;/h3&gt;
		&lt;p&gt;Many websites have some kind of contact form as shown in the following figure. User fills details and presses the "Send" button. This form takes input from the textbox, checkbox, radiobutton etc, builds string containing html and sends information as HTML email. If the form is expecting many values from user, the developer has to write down big chunk of HTML code in the backend. If the developer has to build more than one such forms, it is really cumbersome. To reduce the precious time of developer, this utility module is developed.&lt;/p&gt;
		&lt;p&gt;
				&lt;img src="http://blog.vishalon.net/images/blog/RU1.gif" alt="HTML Utility Snap 1" /&gt;
		&lt;/p&gt;
		&lt;h3&gt;Problem in Direct Rendering of Control&lt;/h3&gt;
		&lt;p&gt;We can use directly Control.Render() method to render html in HTMLTextWriter but with the condition that there should not be any webform controls like TextBox, Label etc. If still we are using this method, it will give error because each server control must be rendered within "form" tag which is having "runat=server" attribute. &lt;/p&gt;
		&lt;h3&gt;Utility Module&lt;/h3&gt;
		&lt;pre lang="VB.Net"&gt;Public Function GetHTML(ByVal objControl As Control) As String&lt;br /&gt;	Dim sb As New System.Text.StringBuilder&lt;br /&gt;	GenerateHTML(objControl, sb)&lt;br /&gt;	Return sb.ToString&lt;br /&gt;End Function&lt;/pre&gt;
		&lt;p&gt;This function takes as argument the control object of which we need to get HTML. It will call private method GenerateHTML() which is responsible for generating HTML for the control.&lt;/p&gt;
		&lt;pre lang="VB.Net"&gt;Private Sub GenerateHTML(ByVal objControl As Control, ByVal sb As System.Text.StringBuilder)&lt;br /&gt;	Dim str As New System.Text.StringBuilder&lt;br /&gt;	Dim sw As New System.IO.StringWriter(str)&lt;br /&gt;	Dim hw As New System.Web.UI.HtmlTextWriter(sw)&lt;br /&gt;	If TypeOf (objControl) Is HtmlTable Then&lt;br /&gt;		sb.Append("&amp;lt;table ")&lt;br /&gt;		CType(objControl, HtmlTable).Attributes.Render(hw)&lt;br /&gt;		sb.Append(str.ToString &amp;amp; " &amp;gt;")&lt;br /&gt;		Dim objControl1 As Control&lt;br /&gt;		For Each objControl1 In objControl.Controls&lt;br /&gt;			GenerateHTML(objControl1, sb)&lt;br /&gt;		Next&lt;br /&gt;		sb.Append("&amp;lt;/table&amp;gt;")&lt;br /&gt;	ElseIf TypeOf (objControl) Is HtmlTableRow Then&lt;br /&gt;		sb.Append("&amp;lt;tr ")&lt;br /&gt;		CType(objControl, HtmlTableRow).Attributes.Render(hw)&lt;br /&gt;		sb.Append(str.ToString &amp;amp; " &amp;gt;")&lt;br /&gt;		Dim objControl1 As Control&lt;br /&gt;		For Each objControl1 In objControl.Controls&lt;br /&gt;			GenerateHTML(objControl1, sb)&lt;br /&gt;		Next&lt;br /&gt;		sb.Append("&amp;lt;/tr&amp;gt;")&lt;br /&gt;	ElseIf TypeOf (objControl) Is HtmlTableCell Then&lt;br /&gt;		sb.Append("&amp;lt;td ")&lt;br /&gt;		CType(objControl, HtmlTableCell).Attributes.Render(hw)&lt;br /&gt;		sb.Append(str.ToString &amp;amp; " &amp;gt;")&lt;br /&gt;		Dim objControl1 As Control&lt;br /&gt;		For Each objControl1 In objControl.Controls&lt;br /&gt;			GenerateHTML(objControl1, sb)&lt;br /&gt;		Next&lt;br /&gt;		sb.Append("&amp;lt;/td&amp;gt;")&lt;br /&gt;	ElseIf TypeOf (objControl) Is LiteralControl Then&lt;br /&gt;		sb.Append(CType(objControl, LiteralControl).Text)&lt;br /&gt;	ElseIf TypeOf (objControl) Is TextBox Then&lt;br /&gt;		sb.Append(CType(objControl, TextBox).Text)&lt;br /&gt;	ElseIf TypeOf (objControl) Is Label Then&lt;br /&gt;		sb.Append(CType(objControl, Label).Text)&lt;br /&gt;	ElseIf TypeOf (objControl) Is CheckBox Then&lt;br /&gt;		Dim chk As CheckBox = CType(objControl, CheckBox)&lt;br /&gt;		sb.Append("&amp;lt;input type='checkbox'" &amp;amp; IIf(chk.Checked, "Checked ", " &amp;gt;") &amp;amp; chk.Text)&lt;br /&gt;	ElseIf TypeOf (objControl) Is RadioButton Then&lt;br /&gt;		Dim rad As RadioButton = CType(objControl, RadioButton)&lt;br /&gt;		sb.Append("&amp;lt;input type='radio'" &amp;amp; IIf(rad.Checked, "Checked &amp;gt;", " &amp;gt;") &amp;amp; rad.Text)&lt;br /&gt;	End If&lt;br /&gt;End Sub&lt;br /&gt;&lt;/pre&gt;
		&lt;p&gt;This function uses recursion to get each element from control hierarchy. It renders HTML code for the control. Currently it supports, HTMLTable, TextBox, CheckBox, RadioButton, Label, and LiteralControl. As this function uses recursion, the processing may be slower than hardcoding the HTML string. So I wrote other function GetCode() which is responsible for emitting source code for building HTML string. This code you can put in a function and get HTML string of the control. The output of both methods are shown in figure. &lt;/p&gt;
		&lt;p&gt;
				&lt;img src="http://blog.vishalon.net/images/blog/RU2.gif" alt="HTML Utility Result Snap" /&gt;
		&lt;/p&gt;
		&lt;h3&gt;Conclusion&lt;/h3&gt;
		&lt;p&gt;If webform is not used very frequently, developer should use, GetHTML() function otherwise they should use use and throw function GetCode(), generate the code, put the code in file and remove this function from solution. &lt;/p&gt;
</description>
			<link>http://article.vishalon.net/Post/51.aspx</link>
			<dc:creator>Vishal Monpara</dc:creator>
			<pubDate>Sat, 24 Sep 2005 19:29:58 GMT</pubDate>
			<guid>http://article.vishalon.net/Post/51.aspx</guid>
		</item>
	</channel></rss>