Saturday, December 11, 2010

Messages Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR.

I was getting following errors while Importing Excel file to SQL Server

Following is list of error details on Importing Excel 2007 to SQL Server 2008
Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80004005  Description: "Could not allocate space for object 'dbo.MyTable'.'PK_MyTable' in database 'MyDatabase_1384_8481' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.".
 (SQL Server Import and Export Wizard)

Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  
The "input "Destination Input" (44)" failed because error code 0xC020907B occurred, and the error row disposition on "input "Destination Input" (44)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.
 (SQL Server Import and Export Wizard)

Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  
The ProcessInput method on component "Destination - MyTable" (31) failed with error code 0xC0209029 while processing input "Destination Input" (44). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the failure. (SQL Server Import and Export Wizard)

Error 0xc02020c4: Data Flow Task 1: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020. (SQL Server Import and Export Wizard) 

Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  
The PrimeOutput method on component "Source - 'ip-to-country$'" (1) returned error code 0xC02020C4.  The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
 (SQL Server Import and Export Wizard)


Work Around to deal with this situation
I have observed that from last couple of month my database has grow unexpectedly without my knowledge, and that was main reason for this error.  So if you encounter this problem, don't follow solution blindly otherwise you would never solve root cause of problem.

Do following
  • Try to go through one by one table and check which table had grown unexpectedly.  Tip try from checking table in which rows are inserted automatically.  Example: Errorlog tables and other depends on your application.
  • Ones you find the that table, identify what is causing sudden growth, is it due to code change in application or due to some automatic script run by someone (virus) this problem is causing.  Try to fix that problem.
  • Best approach is to take backup of that table and delete that table and recreate it.  That will fix problem as lot of primary keys are free. 
  • After solving this root cause problem try to apply solution.


Solution
  • Make sure there is enough Hard Disk space where database files are stored on server.
  • Turn on AUTOGROW for file groups.

Now try to Import your Excel File, make sure that you follow all points mentioned in this blog post in order to Import Excel 2007 file to SQL Server.  

Sunday, September 12, 2010

Random Records in SQL Server based on Where Clause

How to get random records in SQL Server based on Where Clause

Syntax

Select Top [No. of Random Records you want]  *
from
(
Select  Col1, Col2
from ActualTableName
where
Col1 Like '%SearchWord%'
) VirtualTable
ORDER BY NEWID()
Note: VirtualTable is table that doesn't exist in database, it is just a placeholder name.


Example
Select Top 1 *
from
(
Select QuestionId, QuestionTitle
from ForumQuestion
Where
ForumQuestion.QuestionTitle Like @SearchKeyword
) MyTable
ORDER BY NEWID()

Friday, August 13, 2010

Android application development tutorial for .Net Developer

Well, I have search lot for "Android application development tutorial for .Net Developer" and other related terms to find any tutorial for .net developer to make android application.  This article is conclusion of my research and good start up point for anyone having little java knowledge or interested in android application development.

Few things you should keep in mind  (Source of Information)
It’s a know fact that Android is an operating system based upon Linux which has a Java programming interface. It offers tools, e.g. a compiler, debugger along with a device emulator combined with particular Java Virtual machine (DVM). Android is made by the Open Handset Alliance which is lead by Google. Android supports 2-D and 3-D graphics utilizing the OpenGL libraries and supports data storage inside a SQLLite database. Google provides for development the Android Development Tools (ADT) for Eclipse to produce Android applications.

Every Android application works in its own process and is isolated from all other running applications. Therefore on misbehaving application cannot harm other Android applications.

If you wish to write programs for Android then according to My online research indicates that the following steps are a good kick off point to to become a master Android programmer:
1. Learn Java. (Its very easy for C# developer)
2. Install the Android Developer Kit, Eclipse, and the Eclipse plug-in for Android programming.
3. Figure out how to use Eclipse with the Android plug-in.
4. Learn how to design Java programs for Android.

So, if you are ready to develop your first "Hello World Application for Android" then here are some good Android tutorial links to start.


If you are new to java or planning to refresh your past java learning then here is good quick start up tutorial for Java

Since android application development market is huge and it just a beginning, so its worth investing time behind it.

Sunday, July 04, 2010

Installing and running FullText Search on SQL Server 2008

Installing FullText Search on SQL Server 2008

1. Download SQL Express with FullText Search capability for SQL Server 2008
http://www.microsoft.com/express/Database/InstallOptions.aspx


2. Select Installation Type as New Installation


















3 During Feature Selection, select Full-Text Search

















4. While Instance Configuration, Create new Instance Configuration.
- Select Named Instance and give new name.  Example: I have given name: MyShriGanesh

















5. Main steps for installation are done, now simply press next with default choices and complete the installation.

6. After Installation login with new instance name created.
- Example: Earlier I have created named instance MyShriGanesh, so i need to login with same named instance in order to take benefit of FullText Search feature.
















7. Now, Create New Database, Run Tables and SPs Scripts and restore database with data.  If you don't have one already, download sample database and use that database.

After installation of sample database your object explorer will look like as follow:

















8. Open Query Window and type following command to test whether FullText Search is installed or not.

Select SERVERPROPERTY('IsFullTextInstalled')
If this query returns a value of '1' then the component is installed.

Now, lets go step by step to run Full Text Search on SQL Server 2008

Step 1: Creating Full Text Catalog in SQL Server 2008
Syntax:
Create FullText Catalog DatabaseNameCatalog

Example:
Create FullText Catalog AdventureWorksCatalog


Step 2: Create FullText Index in SQL Server 2008
Syntax:
Create FullText Index on TableName
(Column1, Column2, ...., ColumnN)
Key Index PK_TablesPrimaryKey on DatabaseNameCatalog
with Change_Tracking Auto
Note:
  • TableName is name of table you would like to create fulltext index.
  • ColumnName is column on which you would like to create fulltext index, it is column you would like to perform search on.
  • PK_TablesPrimaryKey is primary key of table you are creating on fulltext search index.
  • DatabaseNameCatalog is fulltext search catalog created earlier.
Example:
Create FullText Index on Production.ProductDescription
([Description])
Key Index PK_ProductDescription_ProductDescriptionID on AdventureWorksCatalog
with Change_Tracking Auto



Step 3: Running FullText Search Query
There are many different examples of running fulltext query, I would be giving 2 examples of fulltext search query.
Example 1: Using FreeText


Select [Description]
from Production.ProductDescription
Where
FREETEXT([Description],  'Entry Level Bike')


















Example 2: Using Contains
Select [Description] 
from Production.ProductDescription
Where 
Contains([Description],  '"Entry" and "Level" and "Bike"')


















Example 3: Using Weight keyword

Select [Description] 
from Production.ProductDescription
Where 
Contains([Description],  
'ISABOUT (Entry Weight(.8), Level Weight(.4), Bike Weight (.2))')






















Example 4: Using Inflectional keyword


Select [Description]
from Production.ProductDescription
Where
Contains([Description],
'FormsOf (INFLECTIONAL, Entry, Level, Bike)')

















Download SQL Server 2008 R2 Express with FullText Search Feature

Whenever you are trying to download SQL Server 2008 R2 Express using following link
http://www.microsoft.com/express/database/

It doesn't come with FullText Search feature by default.  Default package only consist of SQL Server Database Engine capability.

To download SQL Server 2008 R2 Express with following features


  • SQL Server Database Engine
  • SQL Server Management Studio Express
  • Full-Text Search
  • Reporting Services
Go to following link

Sunday, June 27, 2010

Restore failed for Server - RESTORE HEADERONLY is terminating abnormally

Recently I have upgraded my database from SQL Server 2005 Express to SQL Server 2008 Express, and I have notice on restoring database it started giving me following restore error.

Error Details

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)


------------------------------
ADDITIONAL INFORMATION:


The media family on device 'C:\NorthwindDB.bak' is incorrectly formed. SQL Server cannot process this media family. RESTORE HEADERONLY is terminating abnormally. (Microsoft SQL Server, Error: 3241)


For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.4053&EvtSrc=MSSQLServer&EvtID=3241&LinkId=20476

Few things you should try before going for solution
This error can occurs due to many reasons but you must ensure following before you start for any solution, it would save your lot of time.

1) Ensure Backup copy of Database is good.
- Take a backup and store on machine where you tried to take backup.
- Now create one dummy database and try to restore that database.
- If you are able to restore that database successfully on machine backup was created, than your backup copy is good.

You should alternately try taking backup using following command

BACKUP DATABASE NorthwindDB
TO DISK='C:\HostingSpaces\MyBackupCopy_NorthwindDB.bak' with FORMAT

If you are able to take backup successfully than Backup copy is good.

2) Ensure Backup copy doesn't get corrupted during dowload.
In my case, I have created a backup copy on Hosting Server, than stored it in .Zip Format, and than try to download it using FileZila, with default settings of filezila transfer type, i.e. Auto.

Till this point everything was going good, but still I was not able to restore DB.

3) Important : Open SQL Query window and check version of your SQL Server.
Run following command and see the output.

Select @@Version

It had given me following output
Microsoft SQL Server 2005 - 9.00.4053.00 (Intel X86) May 26 2009 14:24:20 Copyright (c) 1988-2005 Microsoft Corporation Express Edition on Windows NT 6.0 (Build 6002: Service Pack 2)

After running this command i notice that even though i am using SQL Server 2008 express, it is showing that i am using SQL Server 2005

Cause of Error
Even though I am using SQL Server 2008, but it was connected to SQL Server 2005 instance on the machine i was trying to restore.

Remember:  Restoring Database from lower version to higher version would not give error. i.e. SQL Server 2005 to 2008 would not give error.  But restoring from higher version to lower version will always result in error.  In my case  as i was connected to SQL Server 2005 instance it results me in above error.

You should validate that the instance is the right version by "SELECT @@version".


Solution
You need to fix the connection so it is using the SQL 2008 instance.

Try to run the SQL Server 2008 Express install program again, and during Name Instance configuration, specify a Name Instance with a different name.  Example: MachineName\instancename

After installation, logged in with New Instance name created.

Try to create database, create tables for database and try to run restore again.  It will work this time.

More about Instances
An instance of a SQL Server database is just a named installation of SQL Server. The first one you install on any given machine typically is the default instance, which has no specific name - you just connect to it using the (local) name or the name of the server machine.

SQL Server Express typically installs as a SQLExpress instance - so the instance is called SQLExpress, and you connect to it using (local)\SQLExpress or .\SQLExpress or MyServerMachine\SQLExpress.

SQL Server instances are totally independent of one another, and you can basically install as many as you like - you just have to make sure to use unique instance names for each. But when you run the SQL Server Installation again, it will show you what instances are already installed, and prompt you for a new instance name for a new installation.

Remove sql server 2005 express tools - Installing SQL Server 2008

I was trying to install SQL Server 2008 Express edition, and installation wizard was not allowing me to proceed further unless I remove SQL Server 2005 Express tools.

I tried removing SQL Server 2005 Express tools from Uninstall Program window, but still the same error continues.  In order to fix this you must remove following registry key from registry.

Solution
1) Open Run Menu and type regedit.
2) It will open Registry Editor
3) Now go to following location.
HKEY_LOCAL_MACHINE > Software > Microsoft > Microsoft SQL Server > 90

4) Remove Registry Key 90.

Now try to install SQL Server 2008 and it would work this time.

Thursday, June 10, 2010

Difference between .Net 4.0 and .Net 3.5, 2.0

.Net Framework 4.0 comes up with some of major changes as compare to previous versions of .Net Framework 3.5 and 2.0

Following are list of Major Changes in .Net 4.0

  • ControlRenderingCompatabilityVersion Setting in the Web.config File 
  • ClientIDMode Changes 
  • HtmlEncode and UrlEncode Now Encode Single Quotation Marks 
  • ASP.NET Page (.aspx) Parser is Stricter 
  • Browser Definition Files Updated 
  • System.Web.Mobile.dll Removed from Root Web Configuration File 
  • ASP.NET Request Validation 
  • Default Hashing Algorithm Is Now HMACSHA256 
  • Configuration Errors Related to New ASP.NET 4 Root Configuration 
  • ASP.NET 4 Child Applications Fail to Start When Under ASP.NET 2.0 or ASP.NET 3.5 Applications 
  • ASP.NET 4 Web Sites Fail to Start on Computers Where SharePoint Is Installed 
  • The HttpRequest.FilePath Property No Longer Includes PathInfo Values 
  • ASP.NET 2.0 Applications Might Generate HttpException Errors that Reference eurl.axd 
  • Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode Changes to the ASP.NET Code Access Security (CAS) Implementation 
  • MembershipUser and Other Types in the System.Web.Security Namespace Have Been Moved 
  • Output Caching Changes to Vary * HTTP Header 
  • System.Web.Security Types for Passport are Obsolete 
  • The MenuItem.PopOutImageUrl Property Fails to Render an Image in ASP.NET 4 
  • Menu.StaticPopOutImageUrl and Menu.DynamicPopOutImageUrl Fail to Render Images When Paths Contain Backslashes 
Link to find details of all the Major changes in .Net 4.0

ValidateRequest="false" not working in .Net 4.0 (VS.Net 2010)

Recently I have migrated one of my project from .Net 3.5 to .Net 4.0, In other words from .Net 3.5 Project in VS.Net 2008 to .Net 4.0 Project in VS.Net 2010, and I have noticed suddenly my project started giving following error.

Error: System.Web.HttpRequestValidationException
A potentially dangerous Request.Form value was detected from the client (ctl00$CC$txtAnswer=\"... World\r\n\r\nI am doing Testin...\")."} System.Web.HttpRequestValidationException



at System.Web.HttpRequest.ValidateString(String value, String collectionKey, RequestValidationSource requestCollection)
   at System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection)
   at System.Web.HttpRequest.get_Form()
   at System.Web.HttpRequest.get_HasForm()
   at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)
   at System.Web.UI.Page.DeterminePostBackMode()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.displaypost_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\a37c2f81\cfc4c927\App_Web_i2rujncl.9.cs:line 0
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Cause of this error in .Net 4.0 or while working with VS.Net 2010, .Net 4.0 Project
In ASP.NET 4, by default, request validation is enabled for all requests, because it is enabled before the BeginRequest phase of an HTTP request. As a result, request validation applies to requests for all ASP.NET resources, not just .aspx page requests. This includes requests such as Web service calls and custom HTTP handlers. Request validation is also active when custom HTTP modules are reading the contents of an HTTP request.

Solution for ValidateRequest="false" Issue in .Net 4.0

To revert to the behavior of the ASP.NET 2.0 request validation feature, add the following setting in the Web.config file:
<system.web>
<httpRuntime requestValidationMode="2.0" />
</system.web>

Wednesday, June 02, 2010

label does not exist in current context

Error: label does not exist in current context

Scenario:
I have MyPage.aspx which have number of controls, it was working fine, till the point I made heavy changes.  After making lot of changes to MyPage.aspx, when i tried to compile project, it started giving me error: label does not exist in current context.  The problem here was my label control was there on .aspx page, but it was still giving me error at compile time.

Few things I tried which didn't worked

  • Try to switch design view and source view of MyPage.aspx
  • Tried to comment control and try to create same control again.
Cause of Issue:
I have notice even though label control was there on MyPage.aspx it was not their in MyPage.aspx.designer.cs.  So there was something wrong with designer file.

Solution:
  • Delete designer file (Eg: MyPage.aspx.designer.cs)
  • Try to recreate designer file.  
  • delete MyPage.aspx.designer.cs file, now right click on MyPage.aspx and select "Convert to web application" it will create new MyPage.aspx.designer.cs file.
  • At this point when I tried to create designer file i received error, unable to create designer file due to improper html.  After i rectified html on MyPage.aspx and follow the same steps to create designer file, it have created MyPage.aspx.designer.cs
  • Finally my project gets compiled.

Moral of story
I figured out that VS.Net was giving weired error message.  Even though label control was on MyPage.aspx it was throwing wrong error "label does not exist in current context".  Appropriate error message would be something "Resolve improper html..." which would help me to figure out where exactly the problem is... "Don't trust on error message blindly"

Tuesday, May 11, 2010

Download Sharepoint 2010 Virtual Machine

Download Sharepoint 2010 Virtual Machine

Finally Sharepoint 2010 Virtual PC Image is available to Download.

2) Read Installation Instruction of Installing VPC Image.

Important Note:
The Virtual Machines available for download is for 180 day evaluations.  Additionally they will require activation, or re-arming, after a 10 day period after which they will shut down after 2 hours of continuous operation.  To "re-arm" the Virtual Machines use the shortcut provided under Start > All Programs > re-arm > Re-arm Windows (restart required).  This will reset the grace period for 10 days.  This can be done twice.

Sunday, May 02, 2010

Tweet Posting from Asp.net using OAuth - Twitterizer Tutorial

Twitter Tweet Posting from Asp.net Web Application using OAuth.

Main Steps
1) Create Twitter Application.
2) Post Tweet from Asp.net Website using Twitterizer Api

Now, lets understand each steps in more details, step by step.

Create Twitter Application
1) Open http://twitter.com/apps/new
2) Login to twitter and Fill the Application Information as follow.























 - Choose Image for your Twitter Application.
 - Fill in Twitter Application Name.
 - Description of Twitter Application
 - Fill in Application Website name, Organization























- Choose Application Type as "Browser" as we are developing asp.net website to post tweet.
- Callback Url is url where twitter would redirect after authentication.
    - Fill in rest of details as shown in figure and your Twitter Application is ready to use.























Now, lets begin the important part, how to post tweet.

Post Tweet from Asp.net Website using Twitterizer Api
1) Create Asp.net Application
2) Download Twitterizer
3) Add Reference of Twitterizer.dll files to newly created asp.net web application
4) Copy Consumer Key and Consumer Secret generated from Twitter Application.
5) Add Consumer Key and Consumer Secret to web.config file inside AppSettings

    <add key="consumerKey" value="XXXXXXXXXx"/>
    <add key="consumerSecret" value="XXXXXXXXXXXXXXXX"/>

6) In .aspx page arrange the controls as shown in figure.















7) Paste following code in "Authenticate User" Button Click event

protected void btnAuthenticate_Click(object sender, EventArgs e)
{
    // add these to web.config or your preferred location
    var consumerKey = ConfigurationManager.AppSettings["consumerKey"];
    var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
    
    //If User is not valid user
    if (Request.QueryString["oauth_token"] == null)
    {
        //Step 1: Get Request Token
        OAuthTokenResponse RequestToken 
= OAuthUtility.GetRequestToken(consumerKey,                                                 consumerSecret);

        //Step 2: Redirect User to Requested Token
        Response.Redirect("http://twitter.com/oauth/authorize?oauth_token=" 
+ RequestToken.Token);
    }
    else
    {
        //For Valid User
        string Oauth_Token = Request.QueryString["oauth_token"].ToString();
        var accessToken = OAuthUtility.GetAccessToken(consumerKey,
                                              consumerSecret,
                                              Oauth_Token);

        lblMessage.Text = "<b>Hello " 
+ accessToken.ScreenName 
+ ", Welcome to Go4Sharepoint.com Twitter App<b>";

        lblMessage.Text += "<br/> Token: " + accessToken.Token;
        lblMessage.Text += "<br/> TokenSecret: " + accessToken.TokenSecret;
        lblMessage.Text += "<br/> UserId: " + accessToken.UserId;
    } 
}

8) Now run the application and try to click on "Authenticate User" button, it will redirect you to twitter website authenticate user and return back to your asp.net website.


















Click on Authenticate User button.













Press on Allow button after you enter your twitter login account details




















9) Create OAuthToken Object and Post Tweet.
protected void btnPostTweet_Click(object sender, EventArgs e)
{
    // add these to web.config or your preferred location
    var consumerKey = ConfigurationManager.AppSettings["consumerKey"];
    var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
    
    OAuthTokens accessToken = new OAuthTokens();
    accessToken.AccessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    accessToken.AccessTokenSecret = "xxxxxxxxxxxxxxxxxxxx";
    accessToken.ConsumerKey = consumerKey;
    accessToken.ConsumerSecret = consumerSecret;

    TwitterStatus TweetStatus = new TwitterStatus(accessToken);
    TweetStatus.Update(txtTweet.Text + " - http://www.Go4Sharepoint.com");                        
}

10) Type in your Message and Press "Shout on Twitter" button























Now, check your twitter account (Example here: http://twitter.com/aspnetmvp )

















Check out Live Demo of Tweet Posting from Asp.net

Monday, April 26, 2010

Sharepoint 2010 Development Tutorial

Sharepoint 2010 Tutorials for Developers.  Development Tutorial on Sharepoint 2010 by Microsoft.  Hands on Labs on Sharepoint 2010.  Download Link for Sharepoint 2010 Development Tutorial.

Part 1 - Developing a Visual Web Part in Visual Studio 2010
This hands-on lab introduces the Visual Studio 2010 SharePoint development environment. It shows how to build a Visual Web Part using LINQ to SharePoint, and how to connect one Web Part to another Web Part on the page.

Part 2 - Developing a List Definition and Event Receiver in Visual Studio 2010
This hands-on lab walks you through building a list definition for SharePoint 2010 in Visual Studio 2010. It also shows how to build an event receiver for the list in Visual Studio 2010 and deploy it to SharePoint. After the list and event receiver are deployed, you can use the developer dashboard to evaluate the performance of the event receiver.

Part 3 - Developing Advanced Web Parts for SharePoint 2010 with Visual Studio 2010
This hands-on lab shows how to build a Web Part using several SharePoint-specific controls in Visual Studio 2010. Investigate advanced built-in Web Parts, including the Data View Web Part.

Part 4 - Developing with LINQ to SharePoint in Visual Studio 2010
This hands-on lab explores a variety of LINQ queries on SharePoint 2010, going into more depth than the introductory hands-on lab. It also walks you through an exercise of creating a custom content type in Visual Studio 2010.

Part 5 - Developing for SharePoint 2010 with the Client OM and REST in Visual Studio 2010
This hands-on lab introduces the Client object model for use in calling SharePoint 2010 APIs from a client machine. It also shows the use of ADO.NET Data Services to call REST services in SharePoint 2010.

Part 6 - Developing a BCS External Content Type with Visual Studio 2010
This hands-on lab walks you through building an external content type for Business Connectivity Services using Visual Studio 2010. It also builds a form for Microsoft Outlook and shows the data being edited offline in Outlook.

Part 7 - Developing a SharePoint 2010 Workflow with Initiation Form in Visual Studio 2010
This hands-on lab walks you through building a workflow in Visual Studio 2010 for SharePoint 2010. You add an initiation form to the workflow and use an external data exchange activity in the workflow.

Part 8 - Developing SharePoint 2010 User Interface with Silverlight in Visual Studio 2010
This hands-on lab walks you through building Microsoft Silverlight applications for use in SharePoint 2010. You will access SharePoint 2010 data in Silverlight using the Client object model.

Part 9 - Developing SharePoint 2010 Sandboxed Solutions in Visual Studio 2010
This hands-on lab walks you through building a Sandboxed Solution Web Part for SharePoint 2010. It will also add code to the Web Part that overloads the limits placed by the sandboxed solution, and you will review how the solution is shut down.

Part 10 - Developing SharePoint 2010 User Interface Ribbon and Dialog Customizations
This hands-on lab walks you through adding a custom action to the SharePoint 2010 ribbon, and creating a Web Part that uses the Dialog Framework.

Thursday, April 01, 2010

Download Twitterizer Latest Version

Download Twitterizer Latest Version

Twitterizer Version 2 is available for download, with change of this version which is much more stable and more functions, it is better to revise your earlier twitter code with new code.

Download Twitterizer Beta 2

Tuesday, March 09, 2010

Solution on RowNum and Union Query Problem

I was trying to create stored procedure for Paging data.

Query which I tried using to fetch data contains union. I want RowNum for this union query and I was trying to do create query as follow.

Select Id,
Title,
ROW_NUMBER() OVER(ORDER BY Title Desc) as RowNum
from
(
select Col1 as Id,Col2 as Title from Table1
union all
select Col1 as Id, Col2 as Title from Table2
union all
select Col1 as Id,Col2 as Title from Table3
) DataSet1

Above query works fine till I perform where clause on RowNum field. As RowNum is not part of subquery, when I tried to perform filter on RowNum field I was getting following error.

Select Id,
Title,
ROW_NUMBER() OVER(ORDER BY Title Desc) as RowNum
from
(
select Col1 as Id,Col2 as Title from Table1
union all
select Col1 as Id, Col2 as Title from Table2
union all
select Col1 as Id,Col2 as Title from Table3
) MyTable
Where
RowNum BETWEEN (1 * 25) + 1 AND (1 * 25) + 25

Error: Invalid column name 'RowNum'

Solution:

In order to resolve this situation I have placed my Query like this.

Select *
From
(
My Query
) MyTable
Where Clause for RowNum filter

In order to resolve Row_Number() function problem with Union Query, I have modified my query to following.

Select *
From
(
Select Id,
Title,
ROW_NUMBER() OVER(ORDER BY Title Desc) as RowNum
from
(
select Col1 as Id,Col2 as Title from Table1
union all
select Col1 as Id, Col2 as Title from Table2
union all
select Col1 as Id,Col2 as Title from Table3
) MyTable1
) MyTable2
Where
RowNum BETWEEN (1 * 25) + 1 AND (1 * 25) + 25

Sunday, February 28, 2010

Error: Code blocks are not supported in this context

Error: Code blocks are not supported in this context
Stack Trace: at System.Web.UI.ControlBuilder.AppendSubBuilder(ControlBuilder subBuilder) at System.Web.UI.TemplateParser.AppendSubBuilder(ControlBuilder builder, ControlBuilder subBuilder) at System.Web.UI.TemplateParser.ProcessCodeBlock(Match match, CodeBlockType blockType, String text) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
Cause of Error:
This error occurs mainly if your .aspx page, html tags are not closed properly or you have Bad Html tags which could lead to Html Parser error.
Example: I was playing with FreeTextBox, in Html mode. Suddenly a Phone rangup and forget to close Html tag inside FreeTextbox.


<FTB:FreeTextBox ID="FreeTextBox1" runat="Server"
Width="700" Height="500" TabIndex="8" DisableIEBackButton="true">
<Toolbars>
<FTB:Toolbar>
<FTB:InsertHtmlMenu runat="server" Title="Insert Code">
<Items>
<FTB:ToolbarListItem Text="Student" Value="<img
src='<%= Page.ResolveUrl("
~")%&gt;Images/add_buddy.gif' />"
runat="server" />
</Items>
</FTB:InsertHtmlMenu>
</FTB:Toolbar>
</Toolbars>
</FTB:FreeTextBox>

Solution:
Remove Bad Html or rectify Bad Html part from your .aspx page and this error would get resolved.

Saturday, February 27, 2010

Google Buzz Posting from Asp.net Web Application

Earlier I have discuss about how to post tweet from asp.net web application. In this article I would discuss how to post google buzz from asp.net web application.

What is Google Buzz
Google Buzz is Twitter like service from google, inside gmail.

Following Procedure explains how to send google buzz from asp.net website without using google buzz api.

Step 1: As Google Buzz require a valid gmail account. You need to decide, from which gmail account you would like to post google buzz. For this example, i would be posting google buzz from my gmail account. i.e. dotnetguts [at the rate] gmail [dot] com.

Step 2: Enable Google Buzz posting by sending email. Please follow following to do so.
a) Log into your gmail account.

b) Open Google Buzz.

c) Click on Connected Sites link as shown in figure.


d) Click on Add button associated with "Post via buzz@gmail"


e) Click on save button.


Step 3: Open Visual Studio and create new asp.net website.

Step 4: Arrange web control as shown in following figure.



Step 5: Call following Function from Button Click Event.


private void PostBuzzMsg(string strEmail, string strPassword, string BuzzMsg)
{
//Create Mail Message Object with content that you want to send with mail.
System.Net.Mail.MailMessage MyMailMessage =
new System.Net.Mail.MailMessage(strEmail, "buzz@gmail.com",
BuzzMsg + "... http://dotnetguts.blogspot.com", string.Empty);

MyMailMessage.IsBodyHtml = false;

//Proper Authentication Details need to be passed when sending email from gmail
System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential(strEmail, strPassword);

//Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
//For different server like yahoo this details changes and you can
//get it from respective server.
System.Net.Mail.SmtpClient mailClient =
new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

//Enable SSL
mailClient.EnableSsl = true;

mailClient.UseDefaultCredentials = false;

mailClient.Credentials = mailAuthentication;

mailClient.Send(MyMailMessage);
}

Step 6: Run asp.net website and Send Message.



Now Check your Buzz to see how message appears.

Monday, January 11, 2010

Sharepoint Training Videos

Sharepoint 2010 Training Video

Sharepoint Training for End User

Sharepoint Training for Developer

Sunday, January 03, 2010

Import Excel 2007 into SQL Server 2005

Perfrom following steps to Import Excel 2007 Sheet into SQL Server 2005.


Step 1: Select Destination Database where you would like to Import Excel 2007 Sheet.
Right click database > Tasks > Select Import data... as shown in following figure.


Step 2: Select "Microsoft Office 12.0 Access Database Engine OLE DB Provider" from data source selection drop down. Click on "Properties..." button as shown in figure.


Step 3: Properties dialog box appears.
Click on "Connection Tab" and Enter Excel 2007 file path in Data source text box.

Step 4: Click on "All Tab"
Select "Extended Properties" from given edit values and click on "Edit Value..." button

Step 5: Edit value dialog box appears.
Enter "Excel 12.0" in Property value textbox and click OK button


Step 6: Press Test Connection button to make sure everything is working good.
Finally press OK button.

After that you need to follow usual procedure to import excel sheet data into sql server. i.e. You need to click next and follow wizard instructions.

Append Leading Zero to return value of SQL Select Statement

Append Leading Zero to return value of SQL Select Statement.

Scenario
My SQL table contains USA Zipcode's stored in a numeric format. I have notice that Zipcode with numeric lenght less than 5 has leading zero's.

Here is few example of zipcode containing leading zero's
Rochester, MI 4
Aguadilla PR 603
Caguas PR 726
Ponce PR 731
Belmont MA 2478
Andover NJ 7821
Metuchen NJ 8840
Vernon CT 6066

I want to display correct zipcode every time i fetch value from the database.

So, I want to display zipcode number to always be 5 digits in length. The database might returns a incorrect zipcode, either single digit or up to 4 digits, but I always need enough leading zeros added to the zipcode in order to fit the 5 digit requirement.

Example it should return above zipcode's in following form (Append Leading Zero)
Rochester, MI 00004
Aguadilla PR 00603
Caguas PR 00726
Ponce PR 00731
Belmont MA 02478
Andover NJ 07821
Metuchen NJ 08840
Vernon CT 06066


Solution for displaying leading zero while returning values from SQL Select statement

If your column datatype is Varchar than use following
SELECT City, State, Right(Replicate('0',5) + Zipcode,5) from Location

Or

If your column datatype is Numeric than use following
SELECT City, State, Right(Replicate('0',5) + convert(varchar(6),Zipcode ) ,5) from Location

Most Recent Post

Community Updates

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape