The current time is

Tuesday, November 17, 2009

CodeSmith & NetTiers Custom Stored Procedures

Running the CodeSmith generation tool using the NetTiers templates is a piece of cake if we're going to talk about generating code for database tables. However, when it comes to custom objects being generated by CodeSmith, it gets a bit rocky but it is still doable J

In order to generate code that would encapsulate a stored procedure that you created, you need to follow the steps below:

  1. Your procedure name must be discoverable, meaning that you should set certain settings in CodeSmith so that it could find it during generation. Follow the couple of points below to set the configurations in CodeSmith
    1. IncludeCustoms=true
    2. ProcedurePrefix=<EnterYourProcedurePrefix>
    3. CustomProcedureStartsWith=<EnterYourPattern>

      This pattern uses two placeholders: {0} for the TableName and {1} for the ProcedurePrefix (we've just talked about). So if we need to match the procedure name "myCusProc_myTableName_MethodNameToGenerate", we'll have to set {1} to be "myCusProc_" and appended to it would be the <TableName>. Therefore, the final template we're going to use for this property, CustomProcedureStartsWith, would look like that: {1}{0}_

    4. CustomNonMatchingReturnType=IDataReader|DataSet. You'll have to choose one of these datatypes to return your data in. Usually, I prefer IDataReader.
    5. If you want to generate code for your custom procedures only (i.e: You don't need to re-generate for all your database), then you should set the property ExecuteSQL=false, and the property SourceTables=<TheTablesThatWillContainTheNewlyGeneratedProceduresFunctions>.
    6. Finally, you can verify that CodeSmith generated code for your procedures by checking the Data layer in the base directory for the TableNameProviderBase.generatedCore.cs.


 

Enjoy generating your code J

Wednesday, November 11, 2009

SQL Server 2005 "View Dependencies" "bug"

Couple of days back, I was trying to get the table dependencies in SQL Server 2005, but I faced a weird "bug", I would say, that prevented me from seeing "All" the dependent tables on that specific table. I thought that "View Dependencies" in the SQL Server would find all the tables referencing the one I have selected, check its foreign keys and so, it can list the dependent tables but for some reason, some tables were not retrieved !!! I checked the differences between both tables referencing the parent table and found no differences at all !!!

After searching for this weird issue online, I found this totally "other" way for finding what I wanted which was listed in this website. I tried it and it worked :))

That was the SQL snippet that worked for me :))

-- Value 131527 shows objects that are dependent on the specified object
EXEC sp_MSdependencies N'HumanResources.[Employee]', null, 1315327

-- Value 1053183 shows objects that the specified object is dependent on
EXEC sp_MSdependencies N'HumanResources.[Employee]', null, 1053183

Of course, these numbers, passed as parameters to the procedure, mean something BIGGGG, but who cares for the moment... it's working NOW :)))

Enjoy SQLing :)

Tuesday, August 11, 2009

Type.GetType returning null

Writing code that deals with dynamic objects makes you eventually want to work with the types of the object themselves... So you start using "Type.GetType" and by supplying the type as a string... you get the .NET/custom TYPE itself...

And then comes one day that you're surprised that it's not working like you expected it because simply it's returning null instead of returning the correct type!!!

This is because you did not identify the type correctly/fully...

If the assembly name is specified in the typeName string you supplied, Type.GetType() will search inside this assembly only; otherwise, it tries to find one in the caller assembly and then the system assembly (mscorlib.dll).

So, to make your code work, you'll need to specify the AssemblyQualifiedName. For example:
Type.GetType("System.Drawing.Brush, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")

This whole parameter (inside the GetType method) was retrieved by writing that piece of code:
typeof(System.Drawing.Brush).AssemblyQualifiedName

if you try to get the type by just writing it this way [Type.GetType("System.Drawing.Brush")], it won't work and will return the cutie null... :))

Enjoy the DYNAMICS :)))

Who created evil!!! Nice one :)))


If you wish to translate this post, select the output language from here...




من خلق الشر

هذه الرسالة

تجيب في بلاغة عن واحد من أعمق تساؤلات الحياة

هل الله خلق الشر ؟

تحدى أحد أساتذة الجامعة تلاميذه بهذا السؤال :

هل الله هو خالق كل ماهو موجود ؟

فأجاب أحد الطلبة في شجاعة " نعم "

وكرر الأستاذ السؤال " هل الله هو خالق كل شيء ؟ "

ورد الطالب قائلا " نعم يا سيدي الله خالق جميع الأشياء "

وهنا قال الأستاذ ، " ما دام الله خالق كل شئ ، إذا الله خلق الشر . حيث أن الشر موجود ، وطبقا للقاعدة أن أعمالنا تظهر حقيقتنا ،

" إذا الله شرير "

راح الأستاذ يتيه عجبا بنفسه ، وراح يفتخر أمام الطلبة قائلا

" أنه أثبت مرة أخرى خرافة الإيمان بالله "

وهنا رفع طالب آخر يده وقال " هل لي أن أسألك سؤالا يا أستاذي "

فرد الأستاذ قائلا " بالطبع يمكنك "

وقف الطالب وسأل الأستاذ قائلا " هل البرد له وجود ؟ "

فأجاب الأستاذ " بالطبع موجود ، ألم تشعر مرة به ؟ "

وضحك باقي الطلبة من سؤال زميلهم .

فأجاب الشاب قائلا ، " في الحقيقة يا سيدي البرد ليس له وجود . فطبقا لقوانين الطبيعة ، مانعتبره نحن برداً ، هو في حقيقته غياب الحرارة "

واستطرد قائلا " كل جسم أو شيء يصبح قابلا للدراسة عندما يكون حاملا للطاقة أو ناقلا لها ، والحرارة هي التى تجعل جسما أو شيئا حاملا أو ناقلاً للطاقة " .الصفر المطلق هو –460 فهرنهيت أو –273 مئوية هو الغياب المطلق للحرارة . البرد ليس له وجود في ذاته ولكننا خلقنا هذا التعبير لنصف ما نشعر به عند غياب الحرارة .

استمر الطالب يقول " أستاذي ، هل الظلام له وجود ؟ "

فرد الأستاذ " بالطبع الظلام موجود "

فقال الطالب " معذرة ولكن للمرة الثانية هذا خطأ يا سيدي ، فالظلام هو الآخر ليس له وجود ، فالحقيقة أن الظلام يعنى غياب الضوء .

نحن نستطيع أن ندرس الضؤ ، ولكننا لانستطيع دراسة الظلام . في الحقيقة يمكننا استخدام منشور نيوتن لنفرق الضوء الأبيض لأطياف متعددة الألوان ، ثم ندرس طول موجة كل لون . ولكنك لا تقدر أن تدرس الظلام . وشعاع بسيط من الضوء يمكنه أن يخترق عالم من الظلام وينيره .

كيف يمكنك أن تعرف مقدار ظلمة حيز معين ؟ ، ولكنك يمكنك قياس كمية ضوء موجودة . أليس ذلك صحيحاً ؟ . الظلمة هي تعبير استخدمه الإنسان ليصف ما يحدث عندما لا يوجد النور "

وفى النهاية سأل الطالب أستاذه :

" سيدي ، هل الشر موجود ؟ " ...

وهنا في عدم يقين قال الأستاذ " بالطبع ، كما سبق وقلت ، نحن نراه كل يوم ، وهو المثال اليومي لعدم إنسانية الإنسان تجاه الإنسان . أنه تعدد هذه الجرائم وهذا المقدار الوافر من العنف في كل مكان من العالم حولنا . هذه الظواهر ليست سوى الشر بعينه . "

وعلى هذا أجاب الطالب قائلا " الشر ليس له وجود يا سيدي ، على الأقل ليس له وجود في ذاته .

" الشر ببساطة هو غياب الله "

" أنه مثل الظلام والبرد ، كلمة اشتقها الإنسان ليصف غياب الله . "

الله لم يخلق الشر

الشر هو النتيجة التى تحدث عندما لا يحفظ الإنسان محبة الله في قلبه ،

أنه مثل البرد تشعر به عندما تغيب الحرارة ، أو الظلمة التى تأتى عندما يغيب النور ."

وهنا جلس الأستاذ مذهولا

وكان الشاب الصغير هو

ألبرت اينشتاين

Thursday, August 06, 2009

Visual Studio 2005 Getting Latest while checking out... Feature or Bug !!!

Grrr...
Is this a FEATURE or an annoying aspect in VS 2005...???!!!

Visual SourceSafe and all the similar products are made for managing the "versioning" of files so that the whole team of developers can keep track of the latest versions of the files while they're working in a team...

In Visual Studio 2005, when a developer checks out a file to work on, the VS does not get latest for this file, but it just gives him/her access to modify it by flipping the right access from read only to read/write access. How about if some other colleague changed the contents of this file... If so, then one would have to merge the files when he/she's done... THAT is not a good version control system... One should always get access to modify a latest version of the file. Ain't I right???

I searched online to fix this issue and found this post (http://sela.co.il/?CategoryID=975&ArticleID=501&Page=1) which "says" it has the solution...

I hope it works for you... Let me know if it doesn't and if you've got other solutions to this problem... I hope you'd tell me about it too :)))

Monday, July 20, 2009

Facebook can't run ASP.NET anymore

A user called "Christine Shipley" grabbed default.aspx as her username. This means that facebook is forever blocked from running ASP.NET...

LOL :))))))))

Friday, July 17, 2009

Best Torrent sites

After some re-searching online... I came up with this list of best torrent sites that you can use...
I tried, as much as I can, to prioritize the list... Hope you make use of them... If you've got more sites to add, please feel free to add them as comment to the post... Thanks in advance :)))
ENJOY...

http://www.vertor.com
http://www.isohunt.com
http://www.torrentroot.com
http://www.torrentz.com
http://www.bitsoup.org
http://www.flixflux.co.uk
http://www.demonoid.com
http://www.mininova.org/
http://www.entertane.com

Monday, March 23, 2009

Shrinking the "Unshrinkable" SQL Transaction Log

I've found this "catch" in some blog and thought that I must share it with more people who may have the same problem :)))

Here it goes...

"

Various reasons may cause SQL Server to get in a rut and not empty the transaction log of a database. In my case, our database backups were failing without our knowledge for several weeks, so the backups were never successful, and the transaction logs of a few databases grew so large that the backup process would still not clear out the transaction log. In one case, we had a 187MB database with a 37GB transaction log!

The insanity had to stop! A handful of databases like this would put us over the top on that particular server's hard drive storage.

The SQL Server GUI for shrinking the database rendered no effect, and even using the DBCC SHRINKFILE command was not working.

The key, as explained by Pinal Dave, is to run the SHRINKFILE command twice,with an explicit backup log truncation in between both runs. This code here will get you up and running:

SQL:
  1. DBCC SHRINKFILE("MyDatabase_Log"1)
  2. BACKUP LOG MyDatabase WITH TRUNCATE_ONLY
  3. DBCC SHRINKFILE("MyDatabase_Log"1)

This freed up dozens of gigabytes on our server.

"

Sunday, March 22, 2009

"Unable to load client print control" bug is finally fixed !!!

I finally got this annoying “Printing” error fixed and out of my wayyyy... Yaaaaaaaaaay... So, find the steps here below :)))
First, you have to install the MS Security patch 956391 on all the client machines. They normally would get installed if these machines are running the "Windows Updates"...
Secondly, you should install SQL server Service Pack 3 on Reporting Services 2005: You can find the installation files at this link: http://www.microsoft.com/downloads/details.aspx?FamilyID=ae7387c3-348c-4faa-8ae5-949fdfbe59c4&DisplayLang=en
Finally, you should install Microsoft Report Viewer Redistributable 2005 Service Pack 1 on the Share Point machines. You can find the installation files at this link: http://www.microsoft.com/downloads/details.aspx?familyid=82833F27-081D-4B72-83EF-2836360A904D&displaylang=en

Now, sit back and enjoy printing all your reports :))))))

Monday, January 12, 2009

Some Sharepoint lessons learnt... Just today

Some lessons that I've learnt today:
1- The Sharepoint control "SharePoint:SPGridView"'s columns' HeaderText cannot be bounded in the HTML design view with server tag's values
2- Always do backups for the Sharepoint applications' web.config (I had so many huge issues just because I tried to re-format a web.config file in the visual studio). Those file are better never touched... Take veryyy good caution... :))