Thursday, January 17, 2013

SQL Server Backup Database script

How to create a full database backup in SQL Server 2005, SQL Server 2008 or SQL Server 2012 ?
Note.
- Full database backup take more times to finish and require more storage space.
For the large database you should database backup with differential database backup.
- You can estimate the size of a full database backup by using the sp_spaceused system stored procedure.
- BACKUP DATABASE and BACKUP LOG permissions default to members of the sysadmin fixed server role and the db_owner and db_backupoperator fixed database roles. 

DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20), @hhmiss varchar(20) -- used for file name
 -- SET @path = 'C:\Backup\'
SET @path = '\\MAPPATH\'
SET @hhmiss = CONVERT(VARCHAR(20),GETDATE(),108);
SET @hhmiss = SUBSTRING(@hhmiss, 1, 2) + SUBSTRING(@hhmiss, 4, 2) + SUBSTRING(@hhmiss, 7, 2);

SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) + '_' + @hhmiss

 DECLARE db_cursor CURSOR FOR
 SELECT name FROM master.dbo.sysdatabases WHERE name NOT IN ('master','model','msdb','tempdb')

OPEN db_cursor FETCH NEXT FROM db_cursor INTO @name

WHILE @@FETCH_STATUS = 0

BEGIN
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName
FETCH NEXT FROM db_cursor INTO @name
END
CLOSE db_cursor
DEALLOCATE db_cursor

Sunday, November 4, 2012

Get week no from date time C# .Net

The last parameter DayOfWeek.Monday the function will start first day of week on Monday.

int intWeekNO = 0;
intWeekNO = System.Globalization.CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(
                                pTimesheetDate,
                                System.Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

First Date of Week C# .Net

When you need to find first date of week?

 public static DateTime FirstDateOfWeek(int year, int weekOfYear)
        {
            DateTime jan1 = new DateTime(year, 1, 1);

            int daysOffset = (int)System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek - (int)jan1.DayOfWeek;

            DateTime firstMonday = jan1.AddDays(daysOffset);

            int firstWeek = System.Globalization.CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(jan1, System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat.CalendarWeekRule, System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek);

            if (firstWeek <= 1)
            {
                weekOfYear -= 1;
            }

            return firstMonday.AddDays(weekOfYear * 7);
        }

Monday, October 29, 2012

Enable log4net read from Configuration file for windows services

The logging component for .Net one of greatest is log4net.It is very simple, powerful, and extensible.
We can use for the windows, console or asp.net web application and can setting syntax in configuration file (App.config, Web.config).

When using log4net for windows service application you should

Add this line in assembly information file (AssemblyInfo.cs), it will read from your App.config within log4net section.

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

The example in App.config



   

 



   
     
     
     
     
     
     
     
     
     
     
       
     

   

   
     
     
   

 

Sunday, July 22, 2012

Drag and Drop function stop working in Windows 7 (64 bits)

I’ve found in Windows 7 sometimes it unable to use drag and drop files from the explorer shell. Whatever If you have that problem try this to fix it: Press Ctrl+Alt+Del. Press Esc. It's worked great for me. By the way: Thanks Microsoft for yet another reason to use a Mac instead of a PC.

Tuesday, July 17, 2012

How to Setup for create Metro Style apps with Visual Studio 2012

Visual Studio 2012 RC is a family of products, tools, and technologies that you can use to build powerful, high-performance apps. You can create Metro style apps, in addition to desktop, web, phone, and game-console apps, in this release of Visual Studio 2012.

You can develop Metro style apps in a variety of languages:
If you know web development technologies, you can develop a Metro style app using HTML5, Cascading Style Sheets, Level 3 (CSS3), and JavaScript.
If you have developed .NET, Windows Presentation Foundation, or Microsoft Silverlight applications, you can develop a Metro style app using XAML, with code-behind in C++, C#, or Visual Basic.
If you know DirectX, you can develop a Metro style DirectX app using native C++ and HLSL to take full advantage of graphics hardware.
This guide tells you why you want to develop Metro style apps, where to get the tools you need, and how to build your first app.
Important Metro style app development is supported only on Windows 8 Release Preview. You can't develop Metro style apps on Windows 7 or Windows Server 2012.

What's a Metro style app?
At this point, you might be asking, "OK, so what are Metro style apps and how do they differ from desktop apps?" Read this article to learn about what makes Metro style apps different.





Get the Visual Studio 2012 and Windows 8 tools
Download Windows 8 and the free developer tools you need to create Metro style apps: Microsoft Visual Studio Express 2012 RC for Windows 8, Blend for Microsoft Visual Studio 2012 RC for Windows 8, the Windows 8 software development kit (SDK), and project templates for creating new Metro style apps.



Get a free developer license
Before you can start creating Metro style apps, you need a developer license. Fortunately, it's quick and easy to get one.

Wednesday, March 3, 2010

Understanding .NET application options for 32 and 64-bit systems

Introduction

Around mid-nineties, the migration from 16-bit systems to 32-bit systems was in full swing. The benefits were very clear, but unfortunately, the move caused hair pulling for many .NET developers as they needed to learn new memory models, new API functions and changed pointer arithmetic.
In the present day, we are facing a similar situation when moving from 32-bit to 64-bit systems. Luckily, this change is much more modest, and for many applications, not much needs to be done to keep the 32-bit application happily running on a 64-bit system. Because of the virtual machine technology and the way CLR (Common Language Runtime) is written, your .NET application might even automatically convert itself to a 64-bit application.
However, to break through the 2 GB memory limit or use native code or components outside the managed code barrier, you need to pay attention to the way you write your code.
In this article, you are going to learn the basics of moving your ,.NET & C# applications to 64-bit systems. Along the way, you are also going to learn a bit about memory management, code compatibility, and discover migration tips.
 
Note that this article uses the terms "32-bit system" and "64-bit system" in a specific manner. Here, these terms are used to indicate the operating system bitness, and not the bits supported by the computer hardware. Technically speaking, it is perfectly possible to install a 32-bit operating system on a PC capable of running 64-bit operating systems. In this article, bits refer to the installed architecture of the operating system.

The basics of application compatibility

Because the number of available Windows applications is enormous, a new Windows version cannot simply stop running older applications. The same applies when you migrate upwards in the number of bits in the system. Thus, a regular 32-bit application can in many cases continue to run on a 64-bit system without changes to the application code.
When installing, for instance, a 64-bit Windows 7, the DLLs that implement the Windows programming interfaces are natively 64-bit. This might lead you to think that 32-bit applications would not be able to run, but in fact they can. This is because the operating system supports a feature called Windows-on-Windows (WoW64), which simulates a 32-bit Windows installation inside a 64-bit OS. Because of this, all the 32-bit applications think that they are running just as before, and in many cases work right out of the box.

About memory allocation limits in .NET applications

One of the primary reasons of moving to 64-bit architecture is the ability to use more memory. By default, 32-bit Windows applications are limited to 2 GB of memory (virtual address space). For many applications, this is enough, but high-end applications or those manipulating large amounts of data (be it images, video, statistical input or SQL databases) can run faster, if they can process larger amounts of memory without dividing the data into smaller chunks.
For .NET developers, understanding low-level memory management hasn't been necessary, as the CLR handles all the rudimentary work. Instead, it is enough to simply instantiate objects, and let the runtime handle the rest. The same applies in 64-bit systems, but even if you are running your .NET application on a 64-bit system, you cannot simply start allocating huge, multi-gigabyte arrays right away.
Instead, there's a limit on the size of any single object in .NET. For instance, you cannot allocate a byte array larger than approximately two gigabytes minus 64K. This limitation applies to both 32-bit and 64-bit applications. It would be great if you could allocate multi-gigabyte arrays in 64-bit applications, but unfortunately, this is not the case.
However, when your application is a 64-bit one (or runs on a 64-bit system when built with the Any CPU platform target), you can happily allocate multiple two gigabyte arrays without any problem, provided of course that there is enough system memory available.
Bear also in mind that the size limitation only applies to single objects. If you have an object that merely holds references (pointers) to other objects, like a list or a collection, you don't need to limit yourself to the roughly two gigabyte limit.

Tuesday, March 3, 2009

Sharepoint - Backing up and Restoring your site

Back up a Web site

Backing up a Web site creates a content migration package, or .cmp file. When you back up a Web site, you can choose to back up either the top-level Web site or the top-level Web site and any subsites. The backup file that you create includes list or library content, security settings, user information, navigation, customizations, and personalizations (such as views, site templates, and content types). The backup file does not include workflows, alerts, and properties stored at the site collection level.

To back up a site, you must have administrator permissions for that site, but you do not require administrative access to the server that is running Windows SharePoint Services 3.0.

  1. On the File menu, click Open Site.
  2. In the Open Site dialog box, browse to and click the Web site that you want to back up, and then click Open.
  3. On the Site menu, point to Administration, and then click Backup Web Site.
  4. In the Backup Web Site dialog box, to include all subsites of the current Web site in the backup, select the Include subsites in archive check box.
  5. If the current Web site is low on available storage space, click Advanced, enter a new location, and then click OK.

    Backing up a Web site requires a location to store temporary backup files. By default, Office SharePoint Designer 2007 uses the current Web site. You can use another site on the same server or a location on another server on the same network — for example, \\Server name\Share name.

  6. In the Backup Web Site dialog box, click OK.
  7. In the File Save dialog box, select the location where you want to store the .cmp file.
  8. In the File name box, type the name for the file, and then click Save.

    If the site that you are backing up or restoring is large, the process can take quite a while.

Tip To determine if there were errors during the backup process, you can check the .log file. The .log file is stored in the Temp folder for your user account. If a log file already exists from a previous backup or restore, a new log file is created with a different file name — for example, smigrate_1.log, smigrate_2.log, and so on. Search the log entries for the following error messages: cannot, could not, failure, server error, timed out, unable to, and the server sent a response.


Restore a Web site

Step 1: Create a new empty Web site as a destination

  1. On the File menu, click New.
  2. In the New dialog box, click the Web Site tab, click General, and then click Empty Web Site.
  3. In the Specify the location of the new Web site box, enter the location where you want to restore the backup site.

    You can restore the site to a different server, and you can restore it as either a new top-level site or a subsite under an existing top-level site.

  4. Click OK.

Tip You can also create an empty Web site through the browser by using the Site Settings or Create pages. For example, when viewing the site in the browser, click Site Actions, and then click Create. On the Create page, under Web Pages, click Sites and Workspaces. Complete the first four sections, but when you get to the Template Selection section, close the browser without making a selection. Do not apply any template — including the Blank Site template — or the restore operation will fail.


Step 2: Restore the backup file to the destination

  1. With the destination site open, on the Site menu, point to Administration, and then click Restore Web Site.
  2. In the File Open dialog box, browse to and click the .cmp file that you want to restore, and then click Open.
  3. If the current Web site is low on available storage space, click Advanced, and then do any of the following:
    • To store the archive files in another temporary location, enter a new location in the Temporary location for archive files box.

      Backing up a Web site requires a location to store temporary backup files. By default, Office SharePoint Designer 2007 uses the current Web site. You can use another site on the same server or a location on another server on the same network — for example, \\Server name\Share name.

    • To store the .log file in another location, enter a new location in the Location for import log file box.

      You might need to choose another location for the .log file if the server cannot write to the default location. By default, Office SharePoint Designer 2007 creates an import .log file in the current Web site. You can check this file to determine if there were errors during the restore process.

  4. In the Restore Web Site dialog box, click OK to confirm that you want to restore the .cmp file to the current empty Web site.

    If the site that you are backing up or restoring is large, the process can take quite a while.

SharePoint 2007. sharepoint change site collection content database

In SharePoint 2007 when you create an application you specify the name the database to use. Most people, therefore, conclude that an application will use one database. This is not necessarily a very scalable idea. But then you will often hear that an application can have more than one database. The more commonly heard statement is that a Site Collection can have its own database.

True, very true. Each site collection under an application can be made to have its own database. But how? When you create a site collection you are never asked which database to use or if a new database needs to be created.

Well our friends at Microsoft have made this in a very confusing process. But here goes:

* Let's start with creating a new application. When we create the application we tell it to use the following database: WSS_CONTENT_1
* Now create a site collection (SC1) under this application and a few sites under the site collection. All the sites will use the WSS_CONTENT_1 database.
* Now go to Central Administration, Applications, Content Databases. Select WSS_CONTENT_1 and change its status to "Offline".
* Now under Central Administration, Applications, Content Databases create a new content database WSS_CONTENT_2. Make sure its status is "Ready".
* Now create a new site collection SC2 and create a few sites for SC2. They will use WSS_CONTENT_2.
* Now create yet another site under SC1. It will use WSS_CONTENT_1. This is despite the fact that WSS_CONTENT_1 is "Offline."

So what we have achieved through this roundabout way is a content database for each of our site collections SC1 and SC2. It would have been a lot better if when creating a site collection in Central Admin one was asked if a new database is to be created or if one wants to use an existing database.

In the Central Administration, Application Management, Content Database module setting a database offline means that from this point on no new site collection will be created in this database. However this database is still usable and new sub-sites under an existing site collection can be created. One has to be very careful to take each content database offline once a site collection has been created to prevent any other site collection from being created to use it. This way you can make sure that each site collection has its own database.

BTW, the same can be achieved via an stsadm command:

stsadm -o createsiteinnewdb -url http://your.application.com/SiteCollection -owneremail owner@application.com -ownerlogin Application\Owner -sitetemplate sts -title “Title” -databaseserver servername -databasename WSS_Content_Somename

Why would you want a site collection to have its own database? Well that depends on what you are building and is a subject that is best handled in another post.

Wednesday, April 23, 2008

System.Data.OracleClient requires Oracle client
software version 8.1.7 or greater

Problem
When usign System.Data.OracleClient with Oracle9i client, i got the following message while connecting to the Oracle database from and ASP.NET application.

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.

Cause
Security permissions were not properly set when the Oracle 9i Release 2 client was installed on Windows with NTFS. The result of this is that content of the ORACLE_HOME directory is not visible to Authenticated Users on the machine; this again causes an error while the System.Data.OracleClient is communicating with the Oracle Connectivity software from an ASP.NET using Authenticated User privileges.

Solution
To fix the problem you have to give the Authenticated Users group privilege to the Oracle Home directory.

Log on to Windwos as a user with Administrator privileges.
Start Window Explorer and navigate to the ORACLE_HOME folder.
Choose properties on the ORACLE_HOME folder.
Click the “Security” tab of the “Properties” window.
Click on “Authenticated Users” item in the “Name” list.
Uncheck the “Read and Execute” box in the “Permissions” list under the “Allow” column.
Re-check the “Read and Execute” box under the “Allow” column
Click the “Advanced” button and in the “Permission Entries” verify that “Authenticated Users” are listed with permission = “Read & Execute”, and Apply To = “This folder, subfolders and files”. If not, edit that line and make sure that “Apply To” drop-down box is set to “This folder, subfolders and files”. This should already be set properly but it is important that you verify it.
Click the “Ok” button until you close out all of the security properties windows. The cursor may present the hour glass for a few seconds as it applies the permissions you just changed to all subfolders and files.
Reboot, to assure that the changes have taken effect.
Try your application again.

Thursday, April 10, 2008

AutoSuggestMenu 1.1 (ASP.Net with Ajax)

Eric Popivker has released AutoSuggestMenu 1.1, a .NET component for doing the old-faithful-autosuggest feature that helped to get Ajax on the map (pun intended).

Features

Attaches itself to a specified text box.
Utilizes Microsoft AJAX Extensions and JSON to retrieve data from the server.
Uses paging to iterate through a large number of suggestions
Enables user to use up/down keys or mouse to select appropriate item in auto-complete box.
Easy to add to existing ASP.NET applications.
Customize the look of auto-complete box using CSS.
Allows for multiple AutoSuggestMenus on one page.
Supports IE, FireFox and Safari.
All code and demos are included.
Totally free.

Ajaxed: Ajax for classic ASP

Are you writing classic ASP pages and want to join in the Ajax revolution too? Really? Well, Ajaxed is for you. The framework is simialr to xajax for PHP, in that it allows you to tie in to a named function on th eserver side.

It looks like this
JAVASCRIPT:
<!--#include virtual="/ajaxed/ajaxed.asp"-->
<%
set page = new AjaxedPage
page.draw()

sub init() : end sub

sub callback(action)
if action = "add" then page.return(add(page.RF("a"), page.RF("b")))
end sub

function add(a, b)
if not isnumeric(a) then a = 0
if not isnumeric(b) then b = 0
add = cint(a) + cint(b)
end function

sub main() %>

<script>
function added(sum) {
$('c').value = sum;
}
</script>

<form id="frm">
<input type="Text" name="a" id="a"/>+
<input type="Text" name="b" id="b"/>=
<input type="Text" name="c" id="c"/>
<button onclick="ajaxed.callback('add', added)" type="button">calculate</button>
</form>

<% end sub %>

Unleashing Web 2.0: From Concepts to Creativity


TITLE : Unleashing Web 2.0: From Concepts to Creativity (Paperback)
AUTHOR : by Gottfried Vossen (Author), Stephan Hagemann (Author)
PUBLISHER : Morgan Kaufmann publisher
ISBN : 0123740347
EDITION : 1st
PUB DATE : July 27, 2007
LANGUAGE : English

[ R e l e a s e N o t e s ]

The emergence of Web 2.0 is provoking challenging questions for
developers: What products and services can our company provide to
customers and employees using Rich Internet Applications, mash-ups, Web
feeds or Ajax? Which business models are appropriate and how do we
implement them? What are best practices and how do we apply them?

If you need answers to these and related questions, you need this booka
comprehensive and reliable resource that guides you into the emerging
and unstructured landscape that is Web 2.0.

* Presents a complete view of Web 2.0 including services and
technologies
* Discusses potential new products and services and the technology and
programming ability needed to realize them
* Offers how to basics presenting development frameworks and best
practices
* Compares and contrasts Web 2.0 with the Semantic Web Gottfried Vossen
is a professor of Information Systems and Computer Science at the
University of Muenster in Germany. He is the European Editor-in-Chief of
Elseviers Information SystemsAn International Journal. Stephan Hagemann
is a PhD. Student in Gottfrieds research group focused on Web
technologies.

* Presents a complete view of Web 2.0 including services and
technologies
* Discusses potential new products and services and the technology and
programming ability needed to realize them
* Offers how to basics presenting development frameworks and best
practices
* Compares and contrasts Web 2.0 with the Semantic Web

Wednesday, April 9, 2008

ASP.NET 3.5 For Dummies


ASP.NET 3.5 For Dummies

ASP.NET 3.5 For Dummies is an all new version of the popular title that
makes it easy for beginners to create dynamic, data-driven Web
applications on the Microsoft platform. Wherever possible the book
minimizes the amount of code you write by harnessing powerful
design-time tools built into Visual Web Developer 2008 and its free
version, Visual Web Developer 2008 Express. Where coding is required,
the author walks you through the details using familiar concepts from
everyday life. The book includes many examples of "geekspeak"
terminology so you'll feel comfortable in a conversation with
professional ASP.NET programmers. ASP.NET developers will benefit as
well because the book integrates the new features of ASP.NET 3.5 into
the text and sample code. These include LINQ queries, ASP.NET AJAX,
extension methods, Silverlight, and the new ListView control. Using
realistic examples in VB, you learn to create pages that incorporate the
major ASP.NET controls and features. Coverage includes:

- Microsoft's technologies for dynamic Web content
- Installing and using Visual Web Developer 2008 (Express)
- SQL Server Express and handling database tasks
- Generating ASP.NET pages based on a database
- Inserting, sorting, editing, and deleting data
- The ASP.NET AJAX UpdatePanel and the AJAX Control Toolkit
- Understanding LINQ syntax including From, Where, and Select
- Filtering data with the LinqDataSource control
- Creating interfaces with the ListView control
- RSS and the XmlDataSource control
- Master pages, style sheets, themes, skins, and dynamic effects
- Building a sitemap and connecting navigation controls
- Security, authentication, and data validation
- E-commerce shopping cart
- Rooting out bugs and handling errors
- Compilation and deployment

ASP.NET 3.5 Unleashed


ASP.NET 3.5 Unleashed
ASP.NET 3.5 Unleashed is the most comprehensive book available on the
Microsoft ASP.NET 3.5 Framework, covering all aspects of the ASP.NET 3.5
Framework--no matter how advanced.


This edition covers all the new features of ASP.NET 3.5. It explains
Microsoft LINQ to SQL in detail. It includes a chapter on the two new
data access controls introduced with the ASP.NET 3.5 Framework: ListView
and DataPager. With its coverage of ASP.NET AJAX, this book shows you
how to take advantage of Microsoft's server-side AJAX framework to
retrofit existing ASP.NET applications with AJAX functionality. It also
demonstrates how to use Microsoft's client-side AJAX framework to build
the web applications of the future: pure client-side AJAX applications.
All code samples are written in the C# programming language.

- Take advantage of Microsoft's new database query language, LINQ to
SQL, to easily build database-driven web applications
- Learn how to use the new ListView and DataPager data access controls
to build flexible user interfaces
- Take advantage of ASP.NET AJAX when building both server-side and
client-side web applications
- Use the AJAX Control Toolkit to create auto-complete text fields,
draggable panels, masked edit fields, and complex animations
- Design ASP.NET websites
- Secure your ASP.NET applications
- Create custom components
- Build highly interactive websites that can scale to handle thousands
of simultaneous users
- Learn to build a complete ASP.NET 3.5 website from start to
finish-the last chapter of the book includes a sample ASP.NET 3.5 web
application written with LINQ to SQL and ASP.NET AJAX

Download link