Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SharePoint > SharePoint Development
|
SharePoint Development Programming and development for SharePoint Portal Server and Windows SharePoint Services
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SharePoint Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2008, 04:17 AM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in Sharepoint Webpart

Hi all,

    1. I am working in Microsoft Office Sharepoint application.
    2. In that application, .NET application pages are moved to
       sharepoint and successfully run in sharepoint site.
    3. In my sharepoint site, webparts are created using ".NET sharepoint weparts template"
       using Miscrosoft Visual Studio 2005.
    4. In that webpart, employee ID of employee who currently logged in is retrieved from
       SQL Server Database.
    5. While checking database, if resultset is 0, then iam getting a server error 'Cannot find table name'.
    6. But Iam not getting error while resultset is 0 if I run it as a .net application instead of sharepoint webpart.

       The code I used is following:




namespace HRAdminTask
{
    [Guid("66d01870-8e75-4950-99d3-6ca79f072694")]
    public class HRAdminTask : Microsoft.SharePoint.WebPartPages.WebPart
    {
        Common objcom = new Common();
        ReturnUser objReturnUser = new ReturnUser();
        int supervisorId = 0;
        int deptId = 0;
        public HRAdminTask()
        {
            this.ExportMode = WebPartExportMode.All;
        }



        protected override void Render(HtmlTextWriter writer)
        {
            // TODO: add custom rendering code here.
            // writer.Write("Output HTML");
             SPWeb web = SPContext.Current.Web;
             SPUser user1 = web.CurrentUser;

             string[] arUser = new string[100];

             arUser[0] = user1.LoginName;
             int chk = 0;
             string user = "";
             for (int i = 0; i < arUser[0].Length; i++)
             {
                 if (arUser[0].Substring(i, 1).ToString() == @"\")
                 {
                     chk = 1;
                 }

                 if (chk == 1 && arUser[0].Substring(i, 1).ToString() != @"\")
                 {
                     user = user + arUser[0].Substring(i, 1).ToString();

                 }
             }


             Int64 empIDCount = Convert.ToInt64(SqlHelper.ExecuteNonQuery(objcom.D bConnection, CommandType.StoredProcedure, "uspGetEmpJPIIDCount",
                 new SqlParameter("@UserName",user)));
             if (empIDCount > 0)
             {
                 Int64 empid = Convert.ToInt64(SqlHelper.ExecuteNonQuery(objcom.D bConnection, CommandType.StoredProcedure, "uspGetEmpJPIID",
                     new SqlParameter("@UserName", user)));
                 Page.Session["user"] = empid.ToString();

         }
         else
             {
                 writer.Write("Your account have not been activated");
             }



    7. I am getting error even if I use try..catch statement.

        Please help me and give a solution for this.

Thank You,
Subhashini Palanivel.








Similar Threads
Thread Thread Starter Forum Replies Last Post
error compiling link usercontrol inside sharepoint mcarola ASP.NET 2.0 Professional 0 December 4th, 2008 03:51 PM
Sharepoint-- webpart to find out who all have loog sindia Visual Studio 2005 0 April 27th, 2007 01:18 AM
Sharepoint Search Error x_ray SharePoint Development 1 April 17th, 2007 04:03 PM
WebPart rrsparihar ASP.NET 2.0 Professional 0 October 4th, 2006 12:20 AM
webpart sawjansee BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 0 June 18th, 2006 12:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.