Friday, September 12, 2008
{C#} Simple Encrypt and Decrypt String
private string EncryptString(string strSource)
{
Byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes(strSource);
string encryptedString = Convert.ToBase64String(b);
return encryptedString;
}
// Decrypt Method
private string DecryptString(string strSource)
{
Byte[] b = Convert.FromBase64String(strSource);
string decryptedString = System.Text.ASCIIEncoding.ASCII.GetString(b);
return decryptedString;
}
C# Convert String into Proper Case
===========================
// Use this Namespace
using System.Globalization;
// Code
string myString = "jEssE PaTricio-jR";
TextInfo TI = new CultureInfo("en-US",false).TextInfo;
Response.Write (TI.ToTitleCase( myString ));
Thursday, September 4, 2008
Connection String - Using sqlDataReader
Assuming that i have my sql server connectionstring configured on my web.config file and my stored procedure named "valStudentProfile" with two varchar parameters "username" and "password" created on my SQL Server 2005.
VB Code
Imports System.Data.SqlClient
'-- this function will validate user and return true or false
'-- by calling stored procedure and passing parameters.
Function AuthenticateUser(ByVal Username As String, ByVal Password As String) As Boolean
Dim oConn As New SqlConnection
oConn.ConnectionString = ConfigurationManager.AppSettings("MyServerName")
oConn.Open()
Dim oComm As New SqlCommand
oComm.Connection = oConn
oComm.CommandType = CommandType.StoredProcedure
oComm.CommandText = "valStudentProfile"
Dim pUser As New SqlParameter("@username", SqlDbType.VarChar)
Dim pPass As New SqlParameter("@password", SqlDbType.VarChar)
pUser.Value = UserName.ToString()
pPass.Value = Password.ToString()
oComm.Parameters.Add(pUser)
oComm.Parameters.Add(pPass)
Dim rd As SqlDataReader = oComm.ExecuteReader()
rd.Read()
'- validate if have records
If rd.HasRows Then
'- initialize my session variable
Session("userid") = rd.Item("userid").ToString()
'return true if record exist in the database
Return True
Else
'- return false if no record found match
Return False
End If
-- disposing objects
oComm.Dispose()
oConn.Dispose()
End Function C# Code
public authUser()
{
string username = txtUsername.ToString();
string password = txtPassword.ToString();
SqlConnection oConn = SqlConnection(ConfigurationManager.AppSettings["MyServerName"]);
conn.open();
SqlCommand oComm = new SqlCommand("valStudentProfile", oConn);
oComm.CommandType = CommandType.StoredProcedure;
oComm.Parameters.Add("@username", SqlDbType.VarChar).Value = username;
oComm.Parameters.Add("@password", SqlDbType.VarChar).Value = password;
SqlDataReader rd = oComm.ExecuteReader();
if (rd.Read())
{
return true;
} else {
return false
}
}
Thursday, July 10, 2008
Can not add the user because a user with that name already exist
Symptoms: When you try to add a user to a Microsoft Office Sharepoint Portal Server 2003 portal site or to a Microsoft Windows Sharepoint Services Web site that is hosted on the portal site, you receive the following error message:
Problem: "Can not add the user because a user with that name already exist"
Cause:
This issue may occur if the following conditions are true:
1. You create a user account in the Active Directory service.
2. You add the user to the portal site or to the windows sharepoint services web site.
3. You delete the user accoint from Active Directory. You then create a new user account that uses the same logon name as the user account that you deleted.
4. You try to add the new user account that you created in Active Directory.
Resolution:
To resolve this issue, connect to the Manage Site Collection Users page, and then remove the existing user account. After you do this, add the new user to the portal site or to the Windows SharePoint Services Web site. To do this, follow these steps:
1.
Use on of the following methods to connect to the Manage Site Collection Users page:
•
To connect to the Manage Site Collection Users page of the portal site, type the following address in the address bar of your Web browser, and then press ENTER:
http://ServerName/_layouts/1033/Siteusrs.aspx Note The Manage Site Collection Users page is not revealed in the SharePoint Portal Server 2003 user interface. You have to manually connect to the page.
•
To connect to the Manage Site Collection Users page of a Windows SharePoint Services Web site that is hosted on the portal site, type the following address in the address bar of your Web browser, and then press ENTER:
http://ServerName/Sites/SiteName/_layouts/1033/Siteusrs.aspx
2.
Click to select the check box that is next to the name of the user who you want to remove, and then click Remove Selected Users. Note If more than 100 users are in the site collection, the user may not be listed on the current page. To view additional users, scroll to the bottom of the list of users, and then click Next.
3.
Click OK when you are prompted to confirm the removal.
http://support.microsoft.com/?kbid=893696&FR=1
Wednesday, July 9, 2008
Sequencing 2007 office programs in Microsott
Prescriptive guidance for sequencing 2007 office programs in Microsoft Softgrid
http://support.microsoft.com/default.aspx?scid=kb;EN-US;939796
Best practices to use for sequencing in Microsoft Softgrid
http://support.microsoft.com/kb/932137
Sunday, July 6, 2008
Drop failed for Job Maintanenance
Problem: Unable to delete the plan and the job always prompting error conflicting constraint.
Solution: run the sql script below on your query window.
USE [msdb]
declare @job_name varchar(100)
set @job_name = N'MaintenancePlan'
–First, delete the logs for the plan
delete sysmaintplan_log
FROM sysmaintplan_subplans AS subplans INNER JOIN
sysjobs_view AS syjobs ON subplans.job_id = syjobs.job_id INNER JOIN
sysmaintplan_log ON subplans.subplan_id = sysmaintplan_log.subplan_id
WHERE (syjobs.name = @job_name)
–delete the subplan
delete sysmaintplan_subplans
FROM sysmaintplan_subplans AS subplans INNER JOIN
sysjobs_view AS syjobs ON subplans.job_id = syjobs.job_id
WHERE (syjobs.name = @job_name)
–delete the actual job (You can do the same thing through Management Studio (Enterprise Manager)
delete
from msdb.dbo.sysjobs_view where name = @job_name
If you get this error:
Msg 547, Level 16, State 0, Line 27
The DELETE statement conflicted with the REFERENCE constraint “FK__sysjobsch__job_i__276EDEB3″. The conflict occurred in database “msdb”, table “dbo.sysjobschedules”, column ‘job_id’.
Open the Job and Delete the Schedules
Tuesday, July 1, 2008
How to display icons in a document library
This procedure will guide you to display the image of your file to sharepoint file system.
I will use pdf file as an example.
1. obtain a pdf icon of your choice.
2. rename the image icpdf.gif
3. copy the image to this directory "c:\program files\common files\microsoft shared\web server extensions\60\template\images" on each front-end web server.
4. edit the docicon.xml file located in "c:\program files\common files\microsoft shared\web server extensions\60\template\xml" folder.
5. add this code to your docicon.xml "file
6. restart IIS
Browse to your document library with a pdf document and check if the icon is displayed properly. If you don't see the icon right away just click refresh(F5).
