Tuesday, September 12, 2006

SQL2005 caching

1. run SQL statement below on the database
ALTER DATABASE dbName
SET ENABLE_BROKER

2. use one of the following:
On a page:
On a data source control:
on the page get the data that you want and when its updated the page or data source will be updated

3. GRANT SUBSCRIBE QUERY NOTIFICATIONS TO username
4. GRANT SEND ON SERVICE::SqlQueryNotificationService TO username
anyhow there is a lot restrictions on the use of notification that will let you in the end to leave it.

Friday, August 18, 2006

Web config access denied

A Common developer problem

I have multiple local web servers , (developing, testing and production servers) when I copy my asp.net application between these servers I get this common error, and the IDE says cant start debugging and so on , so my work around is as follow:
  • Remove your files and folders from your application directory (normally under C:\Inetpub\wwwroot/ExampleApp) to another folder
  • Delete the folder and recreate it with IIS
  • Tasks-new virtual directory- entry alias- make a folder, etc
  • Then copy and past (not cut and past) the content to the new directory

This normally is a work around but I don’t think it’s the right solution
I think its something about permissions

Saturday, August 12, 2006

Export Local Reports to Excel/PDF with one click

Local report are great but without an export function so this is one of my approaches to solve this issue.

ReportName : you give the name of the report and its reference path
ReportType : is an enum that is define after the subroutine (Excel/PDF)
DS : is the data set that contain all the information to link with the data
DSName: is the name of the data set so the binding will work

Private Sub ExportReport(ByVal ReportName As String, ByVal ReportType As ReportExportTypes, ByVal DS As DataSet, ByVal DSName As String)
'create report
Dim V As New ReportViewer
V.ProcessingMode = ProcessingMode.Local
V.LocalReport.ReportPath = Server.MapPath(ReportName)
For Each t As DataTable In DS.Tables
V.LocalReport.DataSources.Add(New ReportDataSource(DSName + "_" + t.TableName, t))
Next
' export report
Dim warnings As Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim bytes As Byte()
bytes = V.LocalReport.Render(ReportType.ToString, Nothing, mimeType, encoding, extension, streamids, warnings)
'start exporting
Response.ClearContent()
Response.ClearHeaders()
Response.Buffer = True
Select Case ReportType
Case ReportExportTypes.Excel
Response.ContentType = "application/vnd.ms-excel"
Case ReportExportTypes.PDF
Response.ContentType = "application/pdf"
End Select
Dim oStream As New IO.MemoryStream(bytes)
Response.BinaryWrite(oStream.ToArray())
Response.Flush()
Response.Close()
Response.End()
'cleaning up
oStream.Dispose()
V.Dispose()
End Sub


Public Enum ReportExportTypes
PDF
Excel
End Enum

Monday, August 07, 2006

URL Path Parts

Example of URL Path Parts
Sample URL:
http://www.contoso.com/catalog/shownew.htm?date=today

URL Parts
AbsoluteUri: http://www.contoso.com/catalog/shownew.htm?date=today
Host: www.contoso.com
Authority: www.contoso.com:80
PathAndQuery: /catalog/shownew.htm?date=today
AbsolutePath: /catalog/shownew.htm
Query: ?date=today
Port: 80

Tuesday, July 18, 2006

Enable digrames in sql 2005 after importing from older sql versions

--enable SQL 2005 digrame

EXEC sp_dbcmptlevel 'YourDBName', '90';
go
ALTER AUTHORIZATION ON DATABASE::YourDBName TO "YourLoginName"
go
use [YourDBName]
go
EXECUTE AS USER = N'dbo' REVERT
go

Tuesday, June 27, 2006

Adding a serial number to a GridView

to add a column to your grid view in asp.net 2 you can add the following:

<%# Container.DataitemIndex+1 %>

Saturday, May 20, 2006

Arabic content filps too

Hi
In the last Geeks conference in dubai there was a lot about Arabic interface and other Arabic stuff so I will start to add more articles about this issue here.
I will try to start from were they ended in the conference.
We have an interface that support Arabic and English, the web document goes from left to right to right to left when needed.

So what's new, the data itself. Lets assume we had a drop down list that contain some lookup data (ex: Countries list) when we want to change to Arabic the Browser labels and direction change but not the data. So this is the simplest way I found to change the data itself.

In any field that contain strings that is needed in both languages we will add to the column name in the database table (Arabic) and (English) so if we had a table for countries called Countries and contained an ID and a Name field we will rename the Name field to NameEnglish and Add another field with the name NameArabic

Original Table
Countries

Fields
ID
Name

New Table (Multi Language)
Countries
Fields
ID
NameArabic (better to make the field Unicode for example nvarchar(100))
NameEnglish

In the binding filed of the drop down list we will do the following.

If we have the language in the profile
Eval("Name"+Profile.Language.tostring)
The Profile.Language field must contin the word Arabic or English

Or if we have the language in the QueryString:
Eval("Name"+Request.QueryString("Language"))
Note: the query string must contain the string Arabic or the word English

So now not only the interface flips but even the content. This technique can be used in gridview, datalist or any binding context

Sunday, April 23, 2006

Arabic Net Blog

here we want to talk about the Arabic futures and problems with the net framework.