Skip to main content

Posts

Showing posts from 2009

SBO - Internal Error (-5002) Occured in Inventory Transfer

this is something that not well documented in SBO, it took me several hours to look at Google and can't find anything about it. Thank God friend of mine got answer for this one.So the Sympton is something like this, u need to make Inventory Transfer for Batch Item and Serial Item in one single Transaction so the Transaction is the combination of it. ex in detail lines: 1. Serial Item 2. Batch Item 3. Batch Item 4. Batch Item 5. Serial Item 6. Serial Item . When u reach this code oStockTransfer.Add it will return an error "Internal Error (-5002) Occured". This is because ur details is not in order, meaning u need to order the line with combination of Batch first then Serial or Serial first then Batch so be careful with this thing :D see u

Different kind of Format in VS.Net

Format specifier Name Description C or c Currency The number is converted to a string that represents a currency amount. The conversion is controlled by the currency format information of the NumberFormatInfo object used to format the number. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default currency precision given by the NumberFormatInfo is used. D or d Decimal This format is supported for integral types only. The number is converted to a string of decimal digits (0-9), prefixed by a minus sign if the number is negative. The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. E or e Scientific (exponential) The number is converted to a string of the form "-d.ddd...E+ddd" or "-d.ddd...e+ddd", where each '

Single Sign On in Sharepoint Designer

if u want to using SSO in Sharepoint Designer where it only has parameter for username and password, don't forget to uncheck "Windows Authentication" when u created new Account Information then u can use it in SPD

Installing ASP.NET 2.0

u need to go this folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 and run aspnet_regiis -i, it will installed current version of ASP.NET.. u can verify it on IIS Manager under Web Server Extension until then

The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported

If just in case u found an error something like this The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications then u must enable it it's effected SQL SERVER 2005 and above ALTER DATABASE DB_NAME_HERE SET NEW_BROKER WITH ROLLBACK IMMEDIATE ALTER DATABASE DB_NAME_HERE SET ENABLE_BROKER -- to check whether the broker already enabled or not (1 = enabled, 0 = disabled) SELECT is_broker_enabled FROM sys.databases WHERE name = 'DB_NAME_HERE '

Replace space between words using Query

once a friend of mine asking how to replace space character between words using query..i say it's easy just use RTRIM and LTRIM function but again he said what about replace the character after that? RTRIM and LTRIM only remove leading and trailing spaces, let say u have this word ' a b c d ', using RTRIM and LTRIM only make it something like this 'a b c d'. what about spaces after the word 'a', 'b', so on?? i thought it was easy, using REPLACE then but that's not what he want because REPLACE only make the word is non-readable so i'm thinking using something like this DECLARE @INITIAL VARCHAR(100) DECLARE @Rest VARCHAR(100) DECLARE @Final VARCHAR(100) DECLARE @CharToFind VARCHAR(5) DECLARE @ReplaceChar VARCHAR(5) DECLARE @found INT SET @Initial = ' a,,b,,,c,,,,,,,,,,d,,,,,,,, ' SET @Final = '' SET @CharToFind =',' SET @ReplaceChar ='.' SELECT @Rest = REPLACE(RTRIM(LTRIM(@Initial)), @CharToFind, @R

Hierarchical Query In SQL

it can be done in SQL SERVER 2005 and later using CTE (common table expression) DECLARE @Table1 AS TABLE ( LevelID INT NOT NULL PRIMARY KEY, Position NVARCHAR(50) NOT NULL, ReportingLevelID INT ) INSERT INTO @Table1 SELECT 1, 'Chief Executive Officer', NULL INSERT INTO @Table1 SELECT 2, 'Senior Director - Development', 1 INSERT INTO @Table1 SELECT 3, 'Senior Director - Finance', 1 INSERT INTO @Table1 SELECT 4, 'Senior Director - Human Resources', 1 INSERT INTO @Table1 SELECT 5, 'Product Development Manager', 2 INSERT INTO @Table1 SELECT 6, 'Project Lead', 5 INSERT INTO @Table1 SELECT 7, 'QA Lead', 5 INSERT INTO @Table1 SELECT 8, 'Documentation Lead', 5 INSERT INTO @Table1 SELECT 9, 'Developers', 6 INSERT INTO @Table1 SELECT 10, 'Testers', 7 INSERT INTO @Table1 SELECT 11, 'Writers', 8 INSERT INTO @Table1 SELECT 12, 'Accountants', 3 INSERT INTO @Table1 SELECT 13, 'HR Profes

Using Variable in Openrowset

u can add something variable in Openrowset to provide "Provider", "Connection", "Query" use something like this DECLARE @Query NVARCHAR(4000) SET @Query = 'SELECT ''Please Select'' AS [Department] UNION ALL SELECT [Department] FROM OPENROWSET( ''SQLNCLI'', ''' + @ConnectionString + ''', ''EXEC SPROC_NAME_HERE'') EXEC (@Query) where the @Connectionstring are Server=SERVER_NAME\INSTANCE_NAME;UID=USER_ID;PWD=PASSWORD;Database=DATABASE;'

UserControl in WebPart

some of you maybe get used of using Web Part extension in Visual Studio Project and build the UI using code without the UI there but i found a simple alternative using User Control and in the Web Part is just some code to load that UserControl. U can debug ur code and it's with UI :D here is what i'm doing.. User Control Project: 1. Create New ASP.NET Web Application. 2. Add New User Control into the Project. 3. Design your User Control, u can add code behind or anything like that. 4. Test the User Control by dragging it to Default.aspx page that automatically created from step 1. 5. Build your Application for the last time (it will have .dll inside bin folder of your application). for now we leave the User Control Project, we go on making our Web Part Object 1. Create New Web Part Project, 2. You can delete the default Webpart project that created then create new one to suit the name or u can use the existing one. 3. Add reference to Microsoft.Sharepoint.dll 4. Add some direct

Imports Users in Active Directory to SQL Server

' Bind to RootDSE - this object is used to ' get the default configuration naming context ' e.g. dc=wisesoft,dc=co,dc=uk set objRootDSE = getobject("LDAP://RootDSE") ' Root of search set to default naming context. ' e.g. dc=wisesoft,dc=co,dc=uk ' RootDSE saves hard-coding the domain. ' If want to search within an OU rather than the domain, ' specify the distinguished name of the ou. e.g. ' ou=students,dc=wisesoft,dc=co,dc=uk" strRoot = objRootDSE.Get("DefaultNamingContext") ' Filter for user accounts - could be modified to search for specific users, ' such as those with mailboxes, users in a certain department etc. strfilter = "(&(objectCategory=Person)(objectClass=User))" ' Attributes to return from the query strAttributes = "sAMAccountName,userPrincipalName,givenName,sn," & _ "displayName,mail, " & _ "title,department," & _ "manager" '

Mark Saturday and Sunday as Holiday in Sharepoint List

at this example i'm using INI file again (read up my previous post to see it) to update Sharpeoint List for 1 year calendar C# IniReader oINI = new IniReader(PATH_TO_INI_FORMAT_HERE); myPWAUrl = oINI.ReadString("DOMAIN", "PWA"); myCalendarList = oINI.ReadString("DOMAIN", "Calendar"); static void UpdateCalendar() { SPSite oSite = new SPSite(myPWAUrl); SPWeb oWeb = oSite.OpenWeb(); //list is already exists then delete it oWeb.Lists[myCalendarList].Delete(); oWeb.Update(); oWeb.Lists.Add(myCalendarList, "Enterprise Holidays", SPListTemplateType.Events); oWeb.Update(); SPList oList = oWeb.Lists[myCalendarList]; oList.OnQuickLaunch = true; oList.Update(); DateTime StartDate = new DateTime(System.DateTime.Today.Year, 1, 1); DateTime CurrentDate; for (int i = 1; i <= 365; i++) { if (i > 1) { CurrentDate = StartDate.AddDays(i - 1); if (CurrentDate.DayOfWeek.ToString() == "Saturday" CurrentDate.DayOfWeek.ToString() == "S

Read INI Files

here is class that make ur life easier when reading an INI file :D when u add this class, u can use it right away..something like this will work first import some namespace C# using Org.Mentalis.Files; IniReader oINI = new IniReader(PATH_TO_INI_FORMAT_HERE); Console.WriteLine(oINI.ReadString("DOMAIN", "Name")); Console.WriteLine(oINI.ReadString("DOMAIN", "SMTP")); the INI file format will be something like attached, as you see it's name are .txt not .ini, it doesn't matter as long the format is an INI file where u have Section (ie: DOMAIN) and Key (ie: "Name" and "SMTP") until then PS: i'm using console application

Write to Log Files

if you want to write some success or failed event to log file, then this is the code first u need to using this namespace C# using System.IO; FileStream file; if (File.Exists("FILE_NAME_HERE")) { file = new FileStream( "FILE_NAME_HERE", FileMode.Append, FileAccess.Write); } else { file = new FileStream( "FILE_NAME_HERE", FileMode.Create, FileAccess.Write); } // Create a new stream to write to the file StreamWriter sw = new StreamWriter(file); // Write a string to the file sw.WriteLine("module: some module have an error at " + System.DateTime.Now.ToString()); // Close StreamWriter sw.Close(); // Close file file.Close();

Get User in Active Directory

here i want to get User's Superior in AD (which is manager in AD hierarchy, see attached) PS: you must set it at Organization Tab in User Properties in Active Directory User and Computers C# private static void GetManager(string _Username, string _Domain) { DirectoryContext context = new DirectoryContext(DirectoryContextType.Domain, _Domain); DomainControllerCollection dcc = DomainController.FindAll(context); foreach (DomainController dc in dcc) { DirectorySearcher ds; using (dc) using (ds = dc.GetDirectorySearcher()) { ds.Filter = String.Format("(sAMAccountName={0})", _Username); ds.PropertiesToLoad.Add("manager"); ds.PropertiesToLoad.Add("mail"); ds.SizeLimit = 1; SearchResul

Emailing User in .NET

i use this code, i forgot where i got it so credit goes to him/her C# MailMessage mailMessage = new MailMessage(_FromAddress, _ToAddress); //mailMessage.CC.Add(_CCAddress); mailMessage.Subject = Program.my1stSubjectText; mailMessage.Body = Program.my1stReminderText; mailMessage.IsBodyHtml = true; mailMessage.Subject = "tes Subject"; mailMessage.Body = "HTML can be use here really :D " SmtpClient mailSender = new SmtpClient("SMTP_SERVER_HERE"); try { mailSender.Send(mailMessage); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } until then

almost a year again since my last post :D

many has change now..i'm try to post my knowledge and make it routine :D now i'm working at new employer since my plan to work by myself is not a great idea (according to my colleague Robby, thx for that) in here, we are M$ partner with product like Sharepoint, Project Server, Custom Development and it involved alot of technology like Workflow, WPF, SQL Reporting Service, Silverlight, Infopath, etc and also .NET of course. So i'm learning alot eventhough not mastering any product yet.. at first i'm working for MOSS and Infopath, a lot confusing day back then since the node documentation about it is nearly nothing (especially InfoPath) and i'm learning it from Google. ok, i thinks that's enough for now..feel free to contact me until then