Thursday, April 8, 2010

Infopath: Code Behind Issue Event ID:5337

Hi,

When I had Code-behind for business logic in Infopath forms like:

XPathNavigator nav = MainDataSource.CreateNavigator();

nav.SelectSingleNode("//my:CurrentUser", NamespaceManager).SetValue("SOME Values");

the following Warning message was shown:

Warning Message:

Object reference not set to an instance of an object.

System.NullReferenceException: Object reference not set to an instance of an object.
at ItemCreation.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<>c__DisplayClassa.b__3()
at Microsoft.Office.InfoPath.Server.Util.DocumentReliability.InvokeBusinessLogic(Thunk thunk)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.b__2(Object sender, LoadingEventArgs e)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass34.b__30()
at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.CallFormCodeWithExceptionHandling(UserMessages userMessages, OMCall d)

An entry has been added to the Windows event log of the server.
Log ID:5337

Seems the Error use to come when ever we try to SET VALUE.

instead of directly setting the value. you can us like

Solution:

You can have a public method

public void writeToNode(XPathNavigator xpathNav, string xpath, string value)

{

xpathNav.SelectSingleNode(xpath, this.NamespaceManager).SetValue(value);

}

And use the following code to set value:

writeToNode(nav,"//my:CurrentUser","Some Values");

Resource: http://www.dennispoint.com/Lists/Posts/Post.aspx?ID=27

Hope IT Helpz
Fauzi

Monday, April 5, 2010

C# method to convert Julian to Gregorian date

Hello there,

I was in urgent need to convert Julian date to Georgian for a asp.net application which reads data from DB2.

The following code was useful.


public static string JulianToDateTime(int julianDate)

{

int RealJulian = julianDate + 1900000;

int Year = Convert.ToInt32(RealJulian.ToString().Substring(0, 4));

int DoY = Convert.ToInt32(RealJulian.ToString().Substring(4));

DateTime dtOut = new DateTime(Year, 1, 1);

return dtOut.AddDays(DoY - 1).ToShortDateString();

}

Hope It Helps

Regards
Fauzi

Sunday, April 4, 2010

How to Find you Black Berry PIN number

Hi

I was trying to find the BB PIN number and found the content from a article:
Type ALT CAP H on your BlackBerry keyboard and a screen will show up showing you your PIN, your IMEI number (International Mobile Equipment Identity), signal strength and battery levels etc...

Resource: http://crackberry.com/quick-way-find-your-pin

Hope it helps
4Z

Thursday, April 1, 2010

xp_sendmail: Procedure expects parameter @user, which was not supplied.

Hello...

When you try to send E-mail from your SQL Server 2005 T-SQL with xp_sendmail, there will be an error message shown as follows:

xp_sendmail: Procedure expects parameter @user, which was not supplied.

And probably when you try to pass @user also, it will say invalid parameter.

It seems in SQL Server 2005, xp_sendmail is obsolete and we can use sp_send_dbmail instead.

Following is the syntax:

EXEC msdb.dbo.sp_send_dbmail
@recipients='vm.mohammedfauzi@gmail.com',
@subject = 'SQL:DataBase Mail Test',
@body = 'Hello Test From SQL.Hello Test From SQL.',
@profile_name = 'The Profile you created in Configure Database Mail',
@body_format = 'HTML'

The following link has screen shots to setup Email Profile in SQL Server : Click Here

Hope it helps

Fauzi