Sandeep Khandelwal's Blog

SharePoint, ASP.net & other related stuffs

Converting Long Raw to String in C#

clock March 22, 2011 05:14 by author Sandeep Khandelwal

Lets face it, Long Raw is not something that we like but recently, I was working on itnegration with Vendor system and apparently Vendor had tons of tables with Long Raw data type as column. Now, coming from .net, it was really hard to comprehend on how to read the data because when you query the table directly, it gives you funky value. Something like 436F6D7061696E616E74202D20436F6D6D656E74733A2054686573652061726520636F6D6D656E7473

Here is a quick code snippet that lets you convert the Oracle Long Raw data type to ascii string.

Select text from table_name where blah=blah;

OracleBinary longRaw = null;
longRaw = oReader.GetOracleBinary(0); // Assuming ordinal 0 is the long raw column; In my case text
string sReturn = string.Empty;
System.Text.Encoding enc = System.Text.Encoding.ASCII;
sReturn = enc.GetString(longRaw.Value);
return sReturn;

The key is the conversion of byte to ascii which System.Text.Encoding.ASCII object allows you to do.

Currently rated 3.3 by 6 people

  • Currently 3.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


SharePoint 2010, Linq and SPMetal

clock March 11, 2011 10:57 by author Sandeep Khandelwal

lets face it, we all love using Linq in SharePoint and want to stay away (as much as possible) from those pesky CAML queries. But recently I across an issue with trying to use the datacontext created via SPMetal. Folks, if you don’t know what SPMetal is, please google or bing – you will get it. But any way, I tried to use the class generated in visual webpart but ran into something very silly. here is the text for the error message when trying to build the project using VS 2010.

Error    1    Could not find an implementation of the query pattern for source type 'Microsoft.SharePoint.Linq.EntityList<TimesheetItem>'.  'Select' not found.  Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'?    c:\development\Test\TestWebPartUserControl.ascx.cs    22    52    TestVisualWebPart

Well, the error message does suggest the solution, but given the brilliant minds that we are - sometimes, we overlook the obvious. And in this case, I thought I had the reference to using Microsoft.SharePoint.Linq;then the error suggestion to add using statement for System.Linq is a moot point. But not really, you need reference to both Microsoft.SharePoint.Linq and Microsoft.Linq. Here is a completed using statement.

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Linq;
using System.Linq;

Hopefully, this post saves some body few hassles and time.

Currently rated 3.0 by 10 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


DevExpress controls and SharePoint

clock March 11, 2011 04:43 by author Sandeep Khandelwal

If you like using DevExpress controls in your traditional asp.net application and would like to continue using them inside SharePoint, here are few steps that you can take to “configure” your webapplication for this setup.

Step 1) Ensure that you do copy local to all devEx assemblies that you are using in the webpart project.
image

Step 2) Open web.config file for your web application. Mine was located here at “C:\inetpub\wwwroot\wss\VirtualDirectories\80”. Then under ConfigSection add a new group as below.

<sectionGroup name="devExpress">
  <section name="compression" type="DevExpress.Web.ASPxClasses.CompressionConfigurationSection, DevExpress.Web.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
  <section name="themes" type="DevExpress.Web.ASPxClasses.ThemesConfigurationSection, DevExpress.Web.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
  <section name="errors" type="DevExpress.Web.ASPxClasses.ErrorsConfigurationSection, DevExpress.Web.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" requirePermission="false" />
</sectionGroup>

Step 3) Under assemblies section add the following lines.

<add assembly="DevExpress.Web.ASPxEditors.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
<add assembly="DevExpress.Web.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
<add assembly="DevExpress.Data.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
<add assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=B88D1754D700E49A" />

Step 4) Under System.webserver –> Modules, add the following line.

<add name="ASPxHttpHandlerModule" type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.2, Version=10.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />

Step 5) Finally, under httpmodules, add the following line.

<add name="ASPxHttpHandlerModule" type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v10.1, Version=10.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />

Thats it, You should be good to go.

Currently rated 3.0 by 10 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Issues with upgrading from Standard to Enterprise SP 2010

clock March 8, 2011 10:05 by author Sandeep Khandelwal

Well, my experience for just “changing” the license key from Standard to Enterprise edition was not really that easy. First of all the textbox where you enter the license keys is grayed out. If this textbox is grayed out, how are we supposed to upgrade?

Any way, got around the problem by going to Central Administration –> Upgrade and Migration –> Enable enterprise feature and then select enterprise edition. This will allow you to enter the license key for SP 2010.

Remember to download and install the CU updates. For latest CU update for SharePoint 2010, please go here.

http://technet.microsoft.com/en-us/sharepoint/ff800847.aspx

Once CU updates are installed, remember to run the Configuration wizard. If you prefer to do the hard-way, you can skip running the configuration wizard and add each service application manually.

But while trying to create a new secure token (Requires  a key), you may see the following error.

“An error occurred during the "Generate Key" process. Please try again or contact your administrator. "

image

The error simply means that

a) Either you have not rebooted since you installed the CU updates

b) The id that you are running under does not have permissions to generate the pass phrase encryption keys and lastly

c) The managed service account that is running the secure store service has read/write access to the secure store service database.

For me, the last one “c” was the problem and once I granted SP_APP_SERVICE account the desired permissions, it was fixed.

That’s it.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


About the author

I work as SharePoint Consultant and Lead ECM Solution Expert for Integration Now (a pioneer in SharePoint solutions in midwest region). Besides having PMP, MCP, MCTS and other technical certifications, I am also an MBA (Finance) from UMKC. I lead & oversee SharePoint engagements in 4 states around Kansas City (MO, KS, IA, & NE).

Tag cloud

Page List

Sign in