Thursday, July 26, 2012

How to Delete UserCustomAction for List in sharepoint 2010

In this post i will explain how to delete the custom action of user for list.By using action collection we can get all the user action events on the list.Then we will go through the all items in this collection up to get the desired location.Finally we can set the new location to action then update the list
SPUserCustomActionCollection cAct = orderlist.UserCustomActions;
foreach (SPUserCustomAction act in cAct)
{
//Microsoft.SharePoint.ListEdit ::By using this we can set the location property for list
if (act.Name.Equals("orders") && act.Location.Equals("Microsoft.SharePoint.ListEdit"))
{
act.Location = "test";
act.Update();
orderlist.Update();
break;
}

Tuesday, July 24, 2012

sharepoint 2013 tutorial and download

Recently share point 2013(beta) has been released with new features.The complete overview of version and features are explained briefly in the below links

1. share point 2013 tutorial
2. share point 2013 developer tutorial
3. Develop apps for share point 2013 tutorial
4. Building apps office
3. share point 2013 download

Monday, July 23, 2012

Export excel data to sharepoint list in sharepoint 2010

Here i will given a simple way to export the data to sharepoint list from excel file which is in documnet library in sharepoint.The data table"Exceldata" has used to get the excel data then bind this data to SPlist.Here first we get the path of the excel file in documnet library ,then using this path in connection string.
string ExcelfileName = Path.GetFileName("http://url/Test.xls");
string ExcelileLocation = Server.MapPath(Excelfilename);                
String Con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ ExcelfileLocation +;Extended Properties=Excel 8.0;";  
OleDbConnection objCn = new OleDbConnection(con);  
DataTable ExcelData= new DataTable();
oleDbDataAdapter Oda = new OleDbDataAdapter("select * from[Sheet1$]", Con);   
oda.Fill(ExcelData); 
SPList ExcelDataList = w.Lists["ExcelDataList"];
for (int j = 0; j <= ExcelData.Rows.Count - 1; j++)
{
SPListItem ExcelDataistItem = ExcelDataList.Items.Add();
for (int i = 0; i <= ExcelData.Columns.Count - 1; i++)
{
string ColName = ExcelData.Rows[0][i].ToString();
ExcelDataistItem[ColName] = ExcelData.Rows[j][i].ToString();
}
ExcelDataistItem.Update();      

Wednesday, July 18, 2012

SQL Server 2012:Complete details of New functions in SSIS

In this post i will give brief explanation about new functions in SSIS.In this version we have four new functions .Those are
LEFT:In previous versions there is no LEFT option in SSIS.In this version it will introduces as one of the string function In ssis and it will be use instead of SUBSTRING function.So by using this we can get left part of string
ex:SELECT LEFT(Full name, 3) 
FROM orders
REPLACENULL:It will use to replace the null values.
ex:REPLACENULL(city, "Hyderabad")
TOKEN:By using this function we can return a substring by using delimiters to separate a string into tokens
ex:TOKEN("Bhaskar developer"," ",1) 
give result as bhaskar
TOKENCOUNT:This function will give the count of tokens in the string which is already convert to token from string using delimiters
Ex:TOKENCOUNT("My name is bhaskar"," ")
The count this token is 4

Friday, July 13, 2012

Bind data to dropdownlist in Asp.net MVC4

In previous articles we have seen how to bind data to dropdownlist in gridview in asp.net,How to create entity data model in MVC,Give the reference to css/java script file in ASP.NET MVC,.In this post i will give an example for binding data to drop downlist with static data and dynamic data(From DataBase) in MVC.To assign the items to drop downlist statically,First we have to put the items into SelectListItem array  in controller.Then we can bind those items to drop down in View
Model:

using System.Web;
using System.Web.Mvc;
using System.Configuration;

namespace Dropdown.Models
{
public class Dropdwon
{
public SelectListItem[] sli { set; get; }
}
}
Controller:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Dropdown.Models;

namespace Dropdown.Controllers
{
public class DropdownController : Controller
{
// GET: /Dropdown/
public ActionResult Index()
{
var sli = new[]{
new SelectListItem {Text = "India"},
new SelectListItem {Text = "US" },
new SelectListItem {Text = "UK" },
new SelectListItem {Text = "Australia" }
};
ViewData["ddlcountryname"] = sli;
return View(sli);
}

}
}
Index.cshtml
@{

    ViewBag.Title = "This is my test";

}

<h2>Bind data to dropdown list in mvc4</h2>

@Html.DropDownList("ddlcountryname")

Using Entity model To bind data:
I have used entity model to bind the data to dropdown from database.Whenever we create a connection we can get  model with our data base.Then we can write LINQ query to get the desired data.Finally we need to convert the data to SelectList from query data

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Dropdown.Models;

namespace Dropdown.Controllers
{
public class CityController : Controller
{
private Test_KrishnaEntities db = new Test_KrishnaEntities();
 
// GET: /City/

public ActionResult Index()
{
List x = new List(); 
var city = from contact in db.Contacts orderby contact.Name
                         select contact.Name;
x.AddRange(city.Distinct());
ViewData["ddlcountryname"] =new  SelectList(x);
return View();
}
}

}

Tuesday, July 10, 2012

Sqlserver 2012:Details about New T-SQL commands

In sqlserver 2012 come up with three new T-SQL commands.Those are TRY_CONVERT(),OFFSET / FETCH,FORMAT().

Detailed Description with Examples:
TRY_CONVERT():
The main advantage of using this command is  we can return NULL values with out exception even if the data type does not match in column.In previous versions when we try to get the numbers as char or chars to numbers we used to get exception.
SELECT TRY_CONVERT(INT,age) from table where ISNUMERIC(age) = 25;

OFFSET / FETCH:
The main thing here is to avoid fetching the entire data from table instead it only provides us up to the required limit.Previously this option is only available in MYSQL
SELECT * FROM emp ORDER BY name OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY;

FORMAT():
BY using this string function we can show the output in desired format.Here i have a simple example to get the money format
SELECT FORMAT(12345.00,‘c’,‘en-us’);

output:12,345.00

Monday, July 9, 2012

Difference between sqlserver 2008 and sqlserver 2012

Title: Difference between SQL Server 2008 and SQL server 2012

In previous articles i explained sqlserver 2008 concepts like Delete duplicate rows/columns from table,
Sql server 2012:
1.The SQL Server 2012 uses 48 bit precision for spatial
2.In SQL server 2012 has unlimited concurrent connections
3.By default it supports 15,000 partitions
4.Available new string functions CONCATE and FORMAT
5.Available new conversion  functions are PARSE ,TRY_CONVERT,TRY_PARSE
6.Microsoft.SqlServer.Dac and Microsoft.SqlServer.Dac.Extensions are introduced to perform  operations on Packages

Sql server 2008:
1.Maximum number concurrent connections to SQL Server 2008 is 32767
2.The SQL Server 2008 uses 27 bit precision for spatial
3.It can support only 1000 partitions
4.The CONCATE and FORMAT not available
5.Not available conversion function which are mentioned in SQL 2012



Thursday, July 5, 2012

login failed for user 'sa' in sql server


This error will arise the below scenarios have done.
1.The user name and pass word is incorrect
2.We don't have an user account with this name


To resolve this error we need to create a new login user using server management studio.Here i will show how to create a user with images
After login in to the server with windows authentication ,we have to collapse the Security menu then right click on login and select New login.We can see the below image how we doing this process.

Give the login name and select the sql server authentication ,then give password for user.After complete this process we can give some roles to this user by selecting server Roles which on top most left side menu item.By default the public role  has assigned to user here.

Finally we can see the created user under login tab as in the below screen.By using created credentials we can login into sql server

Monday, July 2, 2012

Complete details about linq in sharepoint

what is LINQ?
LINQ Stands for Language Integrated Query , which  is used by the .net developers to query and transform the data .LINQ is a new data access paradigm,which allows the users to use SQL like Syntax in various data sources through out the application .
What is the main uses of LINQ?
By Allowing  the backend data resources to decide which way is the best to resolve the query , LINQ can improve the performace of the application .Now with sharepoint supporting the LINQ ,its makes query information for the platform easy through LINQ Query Listing in a condensed and easy format .
what are the fetaures of linq in sharepoint?
1) LINQ processes its queries through Custom Query provider that translaters LINQ quries through CAML ,which is a Collaborative Application Markup language which is later on used by the Sharepoint.
2)LINQ also extends its support in C# 3.0 and Visual Basic 9.0 .Visual Studio Integration for the Entity Creation is also known as SPML .
3)Entity Creation tool SpMetal to export SharePoint List definations to entity Classes used for querying .
4) LINQ can be connected to Sharepoint via ,Sharepoint Object model or through Sharepoint Web Services .
5) LINQ also provides the extended support to update through the entity Type.

Sunday, July 1, 2012

How to Bind data to gridview in asp.net

Title: How to bind data to grid view in asp.net using c#.net

Description:
This is the basic concept of the data binding to data source controls in asp.net.Now i would like to explain and given example on bind data to drop down list in grid view,In this post i will explain how to bind the data to grid view example in asp.net.Here the stored procedure has been used to get the data from sql database.In the same way we can see how to call a stored procedure in this example

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Bind data to gridview in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="grvdoc" AllowSorting="True" Runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>

Code Behind:

protected void Page_Load(Object Sender, EventArgs E) 
{
SqlConnection con=new SqlConnection("Data Source=Test;Initial Catalog=binddata;Integrated Security=true")
SqlCommand cmd = new SqlCommand("fiilldocgridview", con);
cmd.CommandType = CommandType.StoredProcedure;con.Open();
SqlDataAdapter ad = new SqlDataAdapter(cmd);DataSet ds = new DataSet();
try
{
da = new SqlDataAdapter(cmd);
da.Fill(ds, "DoctorsTable");
grvdoc.DataSource = ds;
grvdoc.DataBind();
}
catch
{
throw;
}
finally
{
cmd.Dispose();
con.Close();
con.Dispose();
}
}
}
filldocgridview Stored Procedure:

CREATE PROCEDURE [dbo].[fiilldocgridview]
AS
SELECT * FROM  binddata

Bel