this blog contains information for .net and sql stuffs. You can find various tips and tricks to overcome problem you may be facing in ...
Monday, October 1, 2012
Add Event/Appointment in Google Calendar with Google account credential.
Wednesday, June 6, 2012
Print button is not working in Crystal report viewer
Tuesday, June 5, 2012
Change default time out of strongly typed dataset table adapter command.
Public Sub SetCustomCommandTimeout()
Utility.SetCommandTimeout(CommandCollection)
End Sub
End Class
If (commands IsNot Nothing) Then
If (timeout < 0) Then timeout = GetConfigTimeout()
For Each cmd As System.Data.SqlClient.SqlCommand In commands
cmd.CommandTimeout = timeout
Next
End If
End Sub
Private Shared Function GetConfigTimeout() As Integer
Dim timeOut As Integer
If Not System.Configuration.ConfigurationManager.AppSettings("CommandExecutionTimeOut") Is Nothing Then
timeOut = CType(System.Configuration.ConfigurationManager.AppSettings("CommandExecutionTimeOut"), Integer)
Else
timeOut = 0
End If
Return timeOut
End Function
Tuesday, May 1, 2012
Do not serialize public property or field in a class
Wednesday, February 22, 2012
Programmatically create folder in SharePoint Document library with client object model
SharePoint 2010 has very strong client object library, with the help of client object model we can almost interact with all document related functionality from our application and can interact with SharePoint 2010.
Below is some code snippet for creating new folder in the SharePoint Document Library.
public bool CreateSPFolder(string libname, string correspondance)
{
bool bolReturn = false;
ClientContext ctx = this.GetSPClientContext();
Web web = ctx.Web;
List documentLib = ctx.Web.Lists.GetByTitle(libname);
string targetFolderUrl = libname + "/" + correspondance;
Folder folder = web.GetFolderByServerRelativeUrl(targetFolderUrl);
ctx.Load(folder);
bool exists = false;
try
{
ctx.ExecuteQuery();
exists = true;
}
catch (Exception ex)
{
bolReturn = false;
}
if (!exists)
{
ContentTypeCollection listContentTypes = documentLib.ContentTypes;
ctx.Load(listContentTypes, types => types.Include
(type => type.Id, type => type.Name,
type => type.Parent));
var result = ctx.LoadQuery(listContentTypes.Where
(c => c.Name == "Folder"));
ctx.ExecuteQuery();
ContentType folderContentType = result.FirstOrDefault();
ListItemCreationInformation newItemInfo = new ListItemCreationInformation();
newItemInfo.UnderlyingObjectType = FileSystemObjectType.Folder;
newItemInfo.LeafName = correspondance;
ListItem newListItem = documentLib.AddItem(newItemInfo);
newListItem["ContentTypeId"] = folderContentType.Id.ToString();
newListItem["Title"] = correspondance;
newListItem.Update();
ctx.Load(documentLib);
ctx.ExecuteQuery();
bolReturn = true;
}
return bolReturn;
}
Monday, January 23, 2012
Fix issue HTTP/1.1 200 OK Server: Microsoft-IIS/7.5 Error with a SharePoint 2010 Web Application
Generally, such error comes when we try to browse web-application url. There could be many problems around this problem and depends on it there are different solution for it.
First most common issue around this is that, web application does not contain any site collection at web application root level url, to resolve this you can create site collection from central admin ->Application Management ->Create Site Collection. During creation of site collection, please select your web application where you would like to create.
Second scenario, if you have already site collection created and still this problem occurs. To overcome such problem you have choice to restart IIS, reattach your content database, check services on your pc whether “work station” service is started.
Hope this will help!!
Thursday, January 12, 2012
Prerequisites could not be found for bootstrapping (while upgrading from VS 2005, 2008 to VS 2010)
When you try to add prerequisites, you will be surprised that it will not find your older version any more. Many forums said that Microsoft has disabled it and you need to upgrade to higher version of prerequisites.
You can see that in the given below images that shows unavailability.

To resolve this issue you need to copy boots trapper files.
Older version of VS files can be found at
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages
You need to copy files from above location to below location and once you copy required folders, you will be able to access those in prerequisites.
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages
Cheers!!
Wednesday, January 11, 2012
Adding Footer to SharePoint 2010 Custom Master Page
When you are going to develop custom layout of your SharePoint site, it could be requirement of having footer in the page. V4 master page does not contain any options to set footer in page.
You need to add footer manually to your custom master page.
If you check your master page you will find below line
Just above that line you can add your custom footer section as below sample markup.
Copyright © 2012 Company. All Rights Reserved.
Style for above div
*Customized foooter */
#s4-customfooter{
clear: both;
padding: 10px;
color: #ffffff;
background-color: #4F5E85;
}
Hope this will help!!
Thursday, January 5, 2012
The Project Item "module1" cannot be deployed through a Feature with Farm Scope
You might have faced such error sometime during your deployment of SharePoint projects. Usually this error comes due to lack of availability of particular item in the scope. You have limited items that can be deployed in the scope of web, site, web application and farm level.
Microsoft has prepared a very nice article to list out it. You can check out here
Monday, December 26, 2011
How to get public key token for my dll or exe?
Sometime we need to find our dll or exe’s public token when we have strongly signed out. There is a very nice tool given by .net is sn.exe
Just go to command prompt of visual studio, and type following command. Here please note that you need to set your application folder path where your dll or exe assembly is stored.
Sn – T abc.dll
This will give us public token of abc.dll like below message
Public key token is c8903c1b3f99ec16
Thursday, November 17, 2011
Calendar (datetime picker) type column in windows grid
Usually when we try to find some out of use column in default grid provided by .net, we are not able to do it. We require inheriting base class and then we need to put information inside of it.
Say for example, you require adding datetime picker column to your windows form grid, if you check all supported column types in grid, you won’t find such in it. We require writing custom code for it and then adding that columns in our grid control.
Here is some code for creating date time picker column, please make sure that you can add this code in separate component code and then you can access this column in whole project when ever needs.
using System;
using System.Windows.Forms;
public class CalendarColumn : DataGridViewColumn
{
public CalendarColumn() : base(new CalendarCell())
{
}
public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
// Ensure that the cell used for the template is a CalendarCell.
if (value != null &&
!value.GetType().IsAssignableFrom(typeof(CalendarCell)))
{
throw new InvalidCastException("Must be a CalendarCell");
}
base.CellTemplate = value;
}
}
}
public class CalendarCell : DataGridViewTextBoxCell
{
public CalendarCell()
: base()
{
// Use the short date format.
this.Style.Format = "d";
}
public override void InitializeEditingControl(int rowIndex, object
initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
{
// Set the value of the editing control to the current cell value.
base.InitializeEditingControl(rowIndex, initialFormattedValue,
dataGridViewCellStyle);
CalendarEditingControl ctl =
DataGridView.EditingControl as CalendarEditingControl;
// Use the default row value when Value property is null.
if (this.Value == null)
{
ctl.Value = (DateTime)this.DefaultNewRowValue;
}
else
{
ctl.Value = (DateTime)this.Value;
}
}
public override Type EditType
{
get
{
// Return the type of the editing control that CalendarCell uses.
return typeof(CalendarEditingControl);
}
}
public override Type ValueType
{
get
{
// Return the type of the value that CalendarCell contains.
return typeof(DateTime);
}
}
public override object DefaultNewRowValue
{
get
{
// Use the current date and time as the default value.
return DateTime.Now;
}
}
}
class CalendarEditingControl : DateTimePicker, IDataGridViewEditingControl
{
DataGridView dataGridView;
private bool valueChanged = false;
int rowIndex;
public CalendarEditingControl()
{
this.Format = DateTimePickerFormat.Short;
}
// Implements the IDataGridViewEditingControl.EditingControlFormattedValue
// property.
public object EditingControlFormattedValue
{
get
{
return this.Value.ToShortDateString();
}
set
{
if (value is String)
{
try
{
// This will throw an exception of the string is
// null, empty, or not in the format of a date.
this.Value = DateTime.Parse((String)value);
}
catch
{
// In the case of an exception, just use the
// default value so we're not left with a null
// value.
this.Value = DateTime.Now;
}
}
}
}
// Implements the
// IDataGridViewEditingControl.GetEditingControlFormattedValue method.
public object GetEditingControlFormattedValue(
DataGridViewDataErrorContexts context)
{
return EditingControlFormattedValue;
}
// Implements the
// IDataGridViewEditingControl.ApplyCellStyleToEditingControl method.
public void ApplyCellStyleToEditingControl(
DataGridViewCellStyle dataGridViewCellStyle)
{
this.Font = dataGridViewCellStyle.Font;
this.CalendarForeColor = dataGridViewCellStyle.ForeColor;
this.CalendarMonthBackground = dataGridViewCellStyle.BackColor;
}
// Implements the IDataGridViewEditingControl.EditingControlRowIndex
// property.
public int EditingControlRowIndex
{
get
{
return rowIndex;
}
set
{
rowIndex = value;
}
}
// Implements the IDataGridViewEditingControl.EditingControlWantsInputKey
// method.
public bool EditingControlWantsInputKey(
Keys key, bool dataGridViewWantsInputKey)
{
// Let the DateTimePicker handle the keys listed.
switch (key & Keys.KeyCode)
{
case Keys.Left:
case Keys.Up:
case Keys.Down:
case Keys.Right:
case Keys.Home:
case Keys.End:
case Keys.PageDown:
case Keys.PageUp:
return true;
default:
return !dataGridViewWantsInputKey;
}
}
// Implements the IDataGridViewEditingControl.PrepareEditingControlForEdit
// method.
public void PrepareEditingControlForEdit(bool selectAll)
{
// No preparation needs to be done.
}
// Implements the IDataGridViewEditingControl
// .RepositionEditingControlOnValueChange property.
public bool RepositionEditingControlOnValueChange
{
get
{
return false;
}
}
// Implements the IDataGridViewEditingControl
// .EditingControlDataGridView property.
public DataGridView EditingControlDataGridView
{
get
{
return dataGridView;
}
set
{
dataGridView = value;
}
}
// Implements the IDataGridViewEditingControl
// .EditingControlValueChanged property.
public bool EditingControlValueChanged
{
get
{
return valueChanged;
}
set
{
valueChanged = value;
}
}
// Implements the IDataGridViewEditingControl
// .EditingPanelCursor property.
public Cursor EditingPanelCursor
{
get
{
return base.Cursor;
}
}
protected override void OnValueChanged(EventArgs eventargs)
{
// Notify the DataGridView that the contents of the cell
// have changed.
valueChanged = true;
this.EditingControlDataGridView.NotifyCurrentCellDirty(true);
base.OnValueChanged(eventargs);
}
}