Friday, November 03, 2006
How to find database connection strings
Step 1: Open a notepad application
Step 2: Save the empty file with any name with udl extension (*.udl). Type the filename with extension with in quotes. Step 3: Double click the saved file.
Step 4: It will have 4 tabs (Provider, Connection, Advanced, All). Select "Provider" tab
Step 5: Select the provider. (To connect a database we need a driver or provider. If it is installed in the machine, it will be displayed in the Provider tab) and click Next. For Ex: Microsoft OLE DB for SQL Server
Step 6: Fill the appropriate information in the Connection tab, such as server name, username, password, database. Check the "Allow saving password" option. After filling the information click "Test Connection". It should pop up with the information"Test Connection succeeded".
Step 7: Click "Ok" to close the window. Click "Yes" for the next dialog.
Step 8: Now open the file in notepad. You will get the connection string.
Wednesday, November 01, 2006
When to use SQL Server Cursor
declare @loopvar int
declare @maxcnt int
declare @cnter int
declare @outermax int
create table #temptable (
ROWID INT IDENTITY(1,1),
productgp int )
Insert into #temptableselect distinct id from products where status = 1 order by ID
set @outermax = @@ROWCOUNT
set @cnter = 1
While (@cnter <= @outermax)
Begin
// Do your process here
// Do your process here
set @cnter = @cnter +1
end
Use Cursors only if resultset is less in number, say less than 5000 records.
Monday, July 24, 2006
Remove Auto Complete
Tuesday, June 27, 2006
Microsoft's Code sharing site
It has lot of source code with shared souce code licenses.
Popular products already available on the site include Microsoft's Atlas AJAX development tool kit and Iron Python beta 1
Make use of it.
Friday, June 23, 2006
India Tax Calculator (AY 06 - 07)
http://www.taxmann.com/taxmanndit/xtras/taxcalc.aspx
Tuesday, June 20, 2006
Chip breaks speed record in deep freeze
(800 MHz, 1 GHz, 1.8 GHz , 2.4 GHz, 2.6 GHz, 3 GHz Dualcore, 3.6 GHz)?
If your find the answer in the above line then, it shows you have a Grand old PC
Research has gone to such an extent, and created a chip with clock speed of 350 GHz at room temperature.
It is also possible to have a chip with a clock speed of 1THz (@ - 459 F or 0 K or -273 C ) when liquid helium is used for cooling.
It is made up of (SiGe). Silicon and Germanium, it is manufactured by IBM and Georgia Tech.
For more Information: http://news.zdnet.com/2100-9584-6085568.html
Now imagine how fast your windows will boot and how fast you can do CTRL+C CTRL+V?
AIM: To write a program that can run in watches, remote controls
Yes, Microsoft has done it.
.Net Framework for Usual applications
.Net Compact Framework for PDA and windows mobile (smart phones)
.Net Micro Framework for watches and remote controls.
At present MSN Direct Smart Watch works in .Net Micro Framework platform.
For more information:
http://www.aboutnetmf.com/entry.asp
Is it possible in Java technologies?
Sunday, June 18, 2006
Tracking file download
private void DownloadFile(string strfile)
{
System.IO.Stream iStream = null;
byte[] buffer = new Byte[1000];
int length;
long dataToRead=-1;
bool startstatus=false;
string filepath = strfile;
string filename = System.IO.Path.GetFileName(filepath);
try
{
iStream = new System.IO.FileStream(filepath, System.IO.FileMode.Open,System.IO.FileAccess.Read, System.IO.FileShare.Read);
dataToRead = iStream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
while (dataToRead > 0)
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read the data in buffer.
length = iStream.Read(buffer, 0, 1000);
// Write the data to the current output
Response.OutputStream.Write(buffer, 0, length);
// Flush the data to the HTML output.
Response.Flush();
buffer= new Byte[1000];
dataToRead = dataToRead - length;
if(startstatus == false)
{
// Started downloading
startstatus=true;
}
}
else
{
//prevent infinite loop if user disconnects
dataToRead = -1;
// disconnected or unable to download
}
}
}
catch (Exception ex)
{
dataToRead = -1;
}
finally
{
try
{
if(dataToRead == -1)
{
// disconnected or unable to download
}
else
{
// file successfully downloaded
}
if (iStream != null)
{
//Close the file.
iStream.Close();
}
}
catch(Exception ex)
{
}
}
}
Tuesday, June 06, 2006
Enterprise Library - June 2005
Caching ApplicationBlock
Configuration Application Block
Data Access Application Block
Cryptography Application Block
Exception Handling Application Block
Logging and Instrumentation Application Block
Security Application Block
The following are the links for learning Enterprise library.
Download Enterprise library
Learning materials
Thursday, May 11, 2006
Windows Sharepoint Service - 3
Create a new IIS Web Site
a. Open IIS Manager
b. Right-Click on Webs Sites, New -> Web Site to open the Web Site Wizard
c. Enter a description of WSS and click Next
d. Leave IP Address and Port unchanged, but enter WSS in the Host Headers field and click Next
** This assumes you have a DNS record for WSS and the server IP
e. Click Browse then create a new folder under c:\inetpub called WSS and select it, then click Next
f. On the screen title Web Site Access Permissions click Next
g. Click Finish to complete the Web Site creation
Extend the new IIS Web Site
By extending a virtual server we are effectively installing WSS onto the Web Site.
a. Open SharePoint Central Administration - Start -> Administrative Tools -> SharePoint Central Administration
b. Ensure Windows SharePoint Services administration is displayed, link in left column
c. Click on Configure Virtual Server Settings
d. Click on the WSS link
e. On the Extend Virtual Server page, click on Extend and create a content database
f. On the Extend and create content database page, select Use an existing application pool, and choose MSSharePointAppPool from the dropdown.
** Additional Application Pools can be configured to separate instances of WSS running on a single server and thereby ensuring a fault in one application does not affect another.
g. Enter and email address, for example administrator@localhost and click OK
** Extending the virtual server may take some time
h. When completed click on http://wss/
i. When asked to select a template, chose whichever one suits, for example Team Site
Your new dedicated WSS Team Site farm as now been created, all that is needed it to connect it to the Portal
Configure the Portal to use the new Team Site Farm
Once the new WSS environment has been created, Self Service Site Creation must be enabled and the Portal used to create and manage the team sites needs to be informed of the location of the new environment.
a. Open SharePoint Central Administration - Start -> Administrative Tools -> SharePoint Central Administration
b. Click on the Configure Virtual Server Settings link
c. Click on the WSS link
d. Click on Configure Self-Service Site Creation
e. Ensure the option is set to On and then click OK
f. Open the Portal by browsing to http://portal/
g. Click on the Site Settings link
h. Click on the Change portal site properties and SharePoint site creation settings link
i. In the Location for Creating SharePoint Sites field enter:
http://WSS/_layouts/1033/scsignup.aspx
And click OK
Create a new Team Site
With the portal now configured to use the new dedicated Team Site environment, we can create a new Team Site.
a. Click on the Sites link
b. Click on the Create Site link
c. Enter a Title (eg. Demo Site), URL and Owner for the site and click OK
d. On the Add Link to Site screen, which adds the new site to the Site Registry, leave as default and click on OK
e. Select a Template and click OK
f. Verify that your new Team Site has been successfully created on the WSS virtual server
This is how you create a website and a child site.
There are five site groups in WSS
Guest - By default nothing
Reader - Use Self-Service Site Creation, View Pages, View Items,
Contributor - All rights included in the Reader site group, plus:Add Items, Add/Remove Private Web Parts, Browse Directories. Create Cross-Site Groups, Delete Items, Edit Items, Manage Personal Views, Update Personal Web Parts
Web Designer - All rights included in the Contributor site group, plus: Add and Customize Pages, Apply Themes and Borders, Apply Style Sheets, Cancel Check-out, Manage Lists
Administrator - All rights included in the Web Designer site group, plus: Create Subsites, Manage List Permissions, Manage Site Groups, View Usage DataData
For more information download administrator's userguidehttp://www.microsoft.com/downloads/details.aspx?FamilyID=a637eff6-8224-4b19-a6a4-3e33fa13d230&DisplayLang=en
Windows Sharepoint Service - 2
First we need the installer file. Here you downlaad the installer http://www.microsoft.com/windowsserver2003/technologies/sharepoint/default.mspx
It is just 34 MB
Check whether your machine meet the requirements
Windows 2003
.Net 1.1
IIS 6.0
Sql server 2000/MSDE
Double click on the downloded file STSV2.EXE.
This will cause Windows to decompress the file’s contents and to launch the installation program.
1. The Setup wizard appears, accept the license agreement and click Next to continue.
2. The next screen will ask you if you would like to perform a typical installation or if you would rather set up a server farm.
select the Typical Installation option and click Next.
3. The Setup program will now confirm that it is about to install the SharePoint Services and that the target drive has enough free space. Click the Install button to begin installing the necessary files.
4. As the installation progresses, you might notice a message indicating that Setup is configuring the Microsoft SQL Desktop Engine. The Windows SharePoint Services are dependant on SQL Server. As we all know though, SQL Server can be expensive. If you don’t have SQL Server installed on your server prior to installing the Windows SharePoint Services, Setup will automatically configure the SharePoint Services to use MSDE.
Once you the installtion is complete. Go to control panel>> administrative tools you will see the link to sharepoint adminstration. On double clicking you will see a page where you can create websites in sharepoint portal server and configuring them.
Tuesday, May 02, 2006
How are bit columns stored by the SQL Server?
1. Each field is stored as an 8-bit integer.
2. All bit columns are stored together in 8-bit(byte) groups.
3. Bit columns are stored the same as varbinary columns.
4. All bit columns are stored together in two contiguous bytes since SQL Server only allows 16 bit columns in a row. 5. Each bit column is stored in its respective place in the row as a single bit.
Answer:
2. Microsoft® SQL Server™ optimizes the storage used for bit columns. If there are 8 or fewer bit columns in a table, the columns are stored as 1 byte. If there are from 9 through 16 bit columns, they are stored as 2 bytes, and so on.
Thursday, April 27, 2006
Windows Sharepoint Service - 1
All these time we have traditional ways of sharing information through meetings, docs, assigning task, maintaining contacts, lists, lots of things, version controlling, and many more. Most of the things are available in content management systems. For version controlling we can go for some free tools like CVS and Microsoft Visual Sourcesafe. How to get everything in integrated. How to create sites and share information without programming knowledge. Yes everything is possible if you are ready click Next, Next , ....button (All are wizard). All the above the interfaces is in web. You can administer the site from anywhere in the network.
What is the history behind Sharepoint?
Initially it was started as Sharepoint team services - > STS in 2001
It was based on IIS arch. It was a stateful server. Very difficult to maintain web farm.
Customization was difficult. It was using ISAPI extensions and it was developed in ASP
What are the highlights of sharepoint?
Document sharing
Versioning
Web URL
Administration
Area, Topics
Personal sites
Audiences
SSO (single sign on)
Site search
Integration with biztalk
Indexing...... and many more
Is it licensed?
The basic version is absolutely free and it is just 34MB (Windows Sharepoint services) WSS. About 60% of SPS is made free through this.
and Sharepoint Portal service is a licensed.
What are the requirements?
Windows 2003
IIS 6
.Net 1.1
MSDE / Sql server
Tuesday, April 25, 2006
Hit a server side page through XMLHTTP...
Wanna hit a server side page without submitting the main page…
{
var pageUrl = url + "? + params;
var xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
xmlRequest.open("POST", pageUrl, false);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send(null);
return xmlRequest;
}
var resText = xmlRequest.responseText;
try it out…
Thursday, February 16, 2006
Oracle from unbreakable to unpatchable
All because most people are not used to it does not mean you can claim it is unbreakable.
Courtesy: http://blogs.zdnet.com/Ou/?p=151&tag=nl.e622
Microsoft Office Live
Dont wait click the following link http://officelive.microsoft.com/
Sunday, February 05, 2006
Aspnet_wp.exe could not be started
Last week I had a problem, When I moved to new machine. I was able install everything except ASP.NET, Then I checked the status of Aspnet_wp.exe, it was not running. I re-installed whole asp.net using aspnet_regiis.exe. I was bored and started searching. Then i found, it was due to security in related folders.
WORKAROUND
To work around this problem, verify that the ASPNET account has the correct user rights as follows:
• %windir%\Microsoft.NET\Framework\Version\Temporary ASP.NET Files: Full Control
• %windir%\Temp: Full Control
• Application folder: Read
• %installroot% hierarchy (for example, %windir%\Microsoft.Net\Framework\Version): Read
• %windir%\Assembly: Read
Note This is the global assembly cache. You cannot directly use Windows Explorer to edit ACLs for this folder. Instead, open a command window, and then run the following command:
cacls %windir%\assembly /e /t /p domain\useraccount:RAlternatively, before you use Windows Explorer, run the following command to unregister Shfusion.dll:
regsvr32–u shfusion.dll
After you set user rights in Windows Explorer, run the following command to re-register Shfusion.dll:
regsvr32 shfusion.dll
• Web site root (for example, %root%\Inetpub\Wwwroot) or the path that the default Web site points to: Read
• %windir%\System32: Read (Typically, the ASPNET account has already been granted user rights as a member of the Users group.)
Courtesy : http://support.microsoft.com/default.aspx?kbid=811320
How to remove duplicate rows from a table in SQL Server
SUMMARY
Microsoft SQL Server tables should never contain duplicate rows, nor non-unique primary keys. For brevity, we will sometimes refer to primary keys as "key" or "PK" in this article, but this will always denote "primary key." Duplicate PKs are a violation of entity integrity, and should be disallowed in a relational system. SQL Server has various mechanisms for enforcing entity integrity, including indexes, UNIQUE constraints, PRIMARY KEY constraints, and triggers. Despite this, under unusual circumstances duplicate primary keys may occur, and if so they must be eliminated. One way they can occur is if duplicate PKs exist in non-relational data outside SQL Server, and the data is imported while PK uniqueness is not being enforced. Another way they can occur is through a database design error, such as not enforcing entity integrity on each table. Often duplicate PKs are noticed when you attempt to create a unique index, which will abort if duplicate keys are found.
This message is:
Msg 1505, Level 16, State 1 Create unique index aborted on duplicate key. If you are using SQL Server 2000 or SQL Server 2005, you may receive the following error message:
Msg 1505, Level 16, State 1 CREATE UNIQUE INDEX terminated because a duplicate key was found for object name '%.*ls' and index name '%.*ls'. The duplicate key value is %ls. This article discusses how to locate and remove duplicate primary keys from a table. However, you should closely examine the process which allowed the duplicates to happen in order to prevent a recurrence.
MORE INFORMATION
For this example, we will use the following table with duplicate PK values. In this table the primary key is the two columns (col1, col2). We cannot create a unique index or PRIMARY KEY constraint since two rows have duplicate PKs. This procedure illustrates how to identify and remove the duplicates.
create table t1(col1 int, col2 int, col3 char(50))insert into t1 values (1, 1, 'data value one')insert into t1 values (1, 1, 'data value one')insert into t1 values (1, 2, 'data value two')
The first step is to identify which rows have duplicate primary key values: SELECT col1, col2, count(*)FROM t1GROUP BY col1, col2HAVING count(*) < 1
This will return one row for each set of duplicate PK values in the table. The last column in this result is the number of duplicates for the particular PK value.
col1 col2
1 1 2
If there are only a few sets of duplicate PK values, the best procedure is to delete these manually on an individual basis. For example:
set rowcount 1delete from t1where col1=1 and col2=1
The rowcount value should be n-1 the number of duplicates for a given key value. In this example, there are 2 duplicates so rowcount is set to 1. The col1/col2 values are taken from the above GROUP BY query result. If the GROUP BY query returns multiple rows, the "set rowcount" query will have to be run once for each of these rows. Each time it is run, set rowcount to n-1 the number of duplicates of the particular PK value.
Before deleting the rows, you should verify that the entire row is duplicate. While unlikely, it is possible that the PK values are duplicate, yet the row as a whole is not. An example of this would be a table with Social Security Number as the primary key, and having two different people (or rows) with the same number, each having unique attributes. In such a case whatever malfunction caused the duplicate key may have also caused valid unique data to be placed in the row. This data should copied out and preserved for study and possible reconciliation prior to deleting the data.
If there are many distinct sets of duplicate PK values in the table, it may be too time-consuming to remove them individually. In this case the following procedure can be used:
1. First, run the above GROUP BY query to determine how many sets of duplicate PK values exist, and the count of duplicates for each set.
2. Select the duplicate key values into a holding table.
For example:SELECT col1, col2, col3=count(*)INTO holdkeyFROM t1GROUP BY col1, col2HAVING count(*) > 1
3. Select the duplicate rows into a holding table, eliminating duplicates in the process. For example:SELECT DISTINCT t1.*INTO holddupsFROM t1, holdkeyWHERE t1.col1 = holdkey.col1AND t1.col2 = holdkey.col2
4. At this point, the holddups table should have unique PKs, however, this will not be the case if t1 had duplicate PKs, yet unique rows (as in the SSN example above). Verify that each key in holddups is unique, and that you do not have duplicate keys, yet unique rows. If so, you must stop here and reconcile which of the rows you wish to keep for a given duplicate key value. For example, the query: S
ELECT col1, col2, count(*)FROM holddupsGROUP BY col1, col2
should return a count of 1 for each row. If yes, proceed to step 5 below. If no, you have duplicate keys, yet unique rows, and need to decide which rows to save. This will usually entail either discarding a row, or creating a new unique key value for this row. Take one of these two steps for each such duplicate PK in the holddups table.
5. Delete the duplicate rows from the original table.
For example:DELETE t1FROM t1, holdkeyWHERE t1.col1 = holdkey.col1AND t1.col2 = holdkey.col2 6. Put the unique rows back in the original table.
For example:INSERT t1 SELECT * FROM holddups
Courtesy:: http://support.microsoft.com/default.aspx?scid=kb;en-us;139444
Wednesday, February 01, 2006
Convert Julian Date to System.DateTime
private DateTime ConvertJulianToDateTime(double julianDate)
{
DateTime date;
double dblA, dblB, dblC, dblD, dblE, dblF;
double dblZ, dblW, dblX;
int day, month, year;
try
{
dblZ = Math.Floor(julianDate + 0.5);
dblW = Math.Floor((dblZ - 1867216.25) / 36524.25);
dblX = Math.Floor(dblW / 4);
dblA = dblZ + 1 + dblW - dblX;
dblB = dblA + 1524;
dblC = Math.Floor((dblB - 122.1) / 365.25);
dblD = Math.Floor(365.25 * dblC);
dblE = Math.Floor((dblB - dblD) / 30.6001);
dblF = Math.Floor(30.6001 * dblE);
day = Convert.ToInt32(dblB - dblD - dblF);
if (dblE > 13)
{
month = Convert.ToInt32(dblE - 13);
}
else
{
month = Convert.ToInt32(dblE - 1);
}
if ((month == 1) (month == 2))
{
year = Convert.ToInt32(dblC - 4715);
}
else
{
year = Convert.ToInt32(dblC - 4716);
}
date = new DateTime(year, month, day);
return date;
}
catch (ArgumentOutOfRangeException ex)
{
MessageBox.Show("Julian date could not be converted:\n" + ex.Message, "Conversion Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
date = new DateTime(0);
}
catch (Exception ex)
{
MessageBox.Show("Error converting Julian date:\n" +
ex.Message, "Conversion Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
date = new DateTime(0);
}
return date;
}
To learn more about about Julian dates, visit http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html
Saturday, January 07, 2006
Alternate to PDF
How to create MHTML?
Easy, Just pass the URL to this method
public static bool SaveWebPageToMHTFile( string url, string filePath)
{
bool result=false;
CDO.Message msg = new CDO.MessageClass();
ADODB.Stream stm=null ;
try
{
msg.MimeFormatted =true;
msg.CreateMHTMLBody(url,CDO.CdoMHTMLFlags.cdoSuppressNone, "" ,"" );
stm = msg.GetStream();
stm.SaveToFile(filePath,ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
msg=null;
stm.Close();
result=true;
}
catch
{throw;}
finally
{
//cleanup here
}return result
Sunday, January 01, 2006
Free Modeling tool
For more information: www.gentleware.com