Thursday, August 28, 2008

Store user information on J2ME platform

Problem:

J2ME doesn’t support property files

Solution:

In J2SE properties file can be used to store information but that’s not available on J2ME platform, instead it provides a record store. A sample is available at Sun website.

Sample Link: http://developers.sun.com/mobility/midp/samples/#persist

Problem:

Export excel file from SQL Server 2005. In order to do SQL gave the attached error.

Solution:

Quote: (MSDN)

“By default, SQL Server does not allow ad hoc distributed queries using OPENROWSET and OPENDATASOURCE. When this option is set to 1, SQL Server allows ad hoc access. When this option is not set or is set to 0, SQL Server does not allow ad hoc access.”

MSDN Link: http://msdn.microsoft.com/en-us/library/ms187569.aspx

In order to turn this option on follow the link below

http://www.kodyaz.com/articles/enable-Ad-Hoc-Distributed-Queries.aspx

Tuesday, August 26, 2008

HTTP Post multipart file upload with J2ME

Task:

Upload images from a blackberry device to a website

Solution:

There are a lot of tutorials available to upload form data to a website but we spent sometime looking to post a file to a web server using Multi part. Found the article at Nokia which does the job exactly what we need to do. It’s a very to the point code sample with also a usage sample. Also attaching the code as a zip file incase the link is broken and because the site didn’t have a code download option. All credit goes to Nokia.

Link: http://wiki.forum.nokia.com/index.php/HTTP_Post_multipart_file_upload_with_J2ME

Friday, August 22, 2008

Wednesday, August 20, 2008

ShowDialog Memory leak in WinForm

Recently we had to use a common form to display all the reports for a windows application. For some reason all the reports would work only once. We were using a ReportForm.ShowDialog() to show the report form. Apparently ShowDialog doesn’t dispose the form when its closed as a normal form does when its shown using Form.Visible = True. After a lot of search I came across the article which mentioned that there is a memory leak issue if you don’t dispose the form properly after ShowDialog.

Best Practice according to the article is open the form using the following code and it works, solved our issue.

Quote:

using( SomeDialog sd = new SomeDialog() )
{
sd.ShowDialog();
}

Link:

http://kevin-berridge.blogspot.com/2007_08_01_archive.html

SharePoint Object Browser

Code project article for Sharepoint object browser. It comes very handy when doing programming with sharepoint.

Link:

http://www.codeproject.com/KB/sharepoint/sharepoint_object_browser.aspx

Tuesday, August 12, 2008

Javascript Search Tabs

Nice and short tutorial about using javascript search tabs like google/ yahoo. It has few issues in IE but people have fixed it (check comments).

Link:

http://woork.blogspot.com/2008/01/tabbed-search-bar-using-css-and.html

Wednesday, August 6, 2008

Nice free css template site

Contains templates, menus, tutorials

Link: http://www.free-css.com/

Tuesday, August 5, 2008

Import/Export Sharepoint site

Recently we had to transfer a site from one sharepoint site to a different domain. Sharepoint does give you ability to export site/list templates but it has a limit of 10MB. There are ways to increase the limit through stsadm.exe (max 500MB) but if the file gets too big for export then it doesn't work.

Found this very good and short post which does it without any problems. It uses stsadm to import/export.

Quote:

* stsadm.exe -o export -url http://intranet/test -includeusersecurity -nofilecompression -filename C:\backup

Once you finish your export use the stsadm import command with the same nofilecompression attribute. For example:

* stsadm.exe -o import -url http://intranet/test -includeusersecurity -nofilecompression -filename C:\backup


Link:

http://ragavj.blogspot.com/2008/02/failure-decompressing-data-from-cabinet.html

ReportViewer changes application path once report exported (WinForm)

Apparently a bug, when a report is exported on a winform using the ReportViewer control, it changes the path for the application. If application tries to access any local files then it will look in the directory where the report was exported.

Solution is to save the path before the reportviewer is displayed and change it back to application path when the form is closed. The following two events worked in my case.

Dim _AppDirectory As String

Private Sub ReportViewerForm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

Environment.CurrentDirectory() = Me._AppDirectory


End Sub


Private Sub ReportViewerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me._AppDirectory = Environment.CurrentDirectory()


End Sub



Link:
http://forums.msdn.microsoft.com/en-US/vsreportcontrols/thread/d5d5e224-f906-4c3f-88e0-258ee2b2e149/

Reusing ReportViewer WinForm

Spent sometime figuring out that you can't use multiple Reporting services report unless you call the reset method of ReportViewer.

Link:
http://forums.msdn.microsoft.com/en-US/vsreportcontrols/thread/b039e765-3cc8-43ec-ae67-14b9656bc981/

Quote:

The key is to use the Reset method of ReportViewer.

ReportViewer1.Reset();

I put it above the LocalReport datasource clear/add and it worked!