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.
|