Posts

Showing posts from 2012

Using SqlDependency without providing an options value Error

Using SqlDependency without providing an options value Error. When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance. Using SqlDependency without providing an options value Exception. SqlDependency is awesome.  It truly is.  Problem is it has a lot of unexpected behaviors to an SqlDependency noob.  I got this error: " When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance " couple of hours ago and I decided to share. This error occurs if you didn't started your SqlDependency or it got closed for some reason.  I usually start it this way in the Global.asax :        protected   void  Application_Start( Object  sender,  EventArgs  e)  {    var sConn =  ConfigurationMan...

Get Month Name In Javascript

Month Name in JavaScript. Get Month Name Javascript. Javascript Date Object, Months Names. There's a very simple way to get the month's name in javascript.  The only problem is, that people do it over and over instead of just placing this in the Date object. Do, the solution is rather simple:      Date.prototype.getMonthName =  function () {           var  monthNames = [  "January" ,  "February" ,  "March" ,  "April" ,  "May" ,  "June" ,                           "July" ,  "August" ,  "September" ,  "October" ,  "November" ,  "December"  ];           return  monthNames[ this .getMonth()];      } Next time you'll want to get a name you can just:       var ...

Deleting Folders In Visual Studio

Deleting Folders In Visual Studio. Deleting Folders In TFS. Removing Folders In Visual Studio. Removing Folders In TFS. I just got the most annoying message while trying to delete a folder in Visual Studio 2010 that is connected to TFS: " This operation cannot be completed. You are attempting to remove or delete a source-controlled item where the item is either exclusively locked elsewhere or otherwise unable to be deleted from source control. " The solution is very simple. Create an item inside the folder you are trying to delete.  No need to check in. Now delete that folder. TFS and VS have some weird bug with deleting empty folders, so, this is the fastest workaround. Hope it helped, Elad Shalom, CTO at ITweetLive.com

Find was Stopped in Progress Visual Studio

Image
Find was Stopped in Progress. Visual Studio 2010. Visual Studio 2005.  Visual Studio has some known issues.  One of them is the inability to search something using Ctrl+Shift+F because of the following error: "Find was stopped in progress". Well, a very informative post can be found here but the solution is extremely simple: Ctrl + ScrollLock will fix your problem :) Have fun, Elad Shalom, CTO at ITweetLive.com

DataSet HasTables Method

DataSet Extentions. Add Methods to Objects. So, it's getting me tired to always right:      if (ds != null && ds.Tables.Count > 0) to make sure that a certain dataset really has tables inside. So here is an extension I added to the DataSet object: public   static   bool  HasTables( this   DataSet  ds)         {              if  (ds !=  null  && ds.Tables.Count > 0)                  return   true ;              return   false ;         } Simple, yet efficient :) Elad Shalom, CTO at ITweetLive.com

DataTable HasRows Method

DataTable Extentions. Add Methods to Objects. So, it's getting me tired to always right:      if (dt != null && dt.Rows.Count > 0) to make sure that a certain table really have rows. So here is an extension I added to the DataTable object: public   static   bool  HasRows( this   DataTable  dt)         {              if  (dt !=  null  && dt.Rows.Count > 0)                   return   true ;              return   false ;         } Simple, yet efficient :) Elad Shalom, CTO at ITweetLive.com

Change Primary Key SQL

Change Primary Key in Sql Server 2005 . Change Primary Key in Sql Server 2008. Change PK from Clustered to NonClustered in Sql Server. Just this morning I encountered a problem in my database performance. It appears like the person who created the table created the primary key as a clustered one, without thinking of what will be in the future and the purpose of the Id PK in the table. After digging the web, I found this great answer which gave me the hint for the desired solution: use MyDB DROP INDEX MyTable.IX_MyTable_FamilyName ALTER TABLE MyTable     ADD CONSTRAINT UQ_TableX UNIQUE(Id) ALTER TABLE MyTable     DROP CONSTRAINT PK_MyTable ALTER TABLE MyTable     ADD CONSTRAINT PK_MyTable PRIMARY KEY NONCLUSTERED(Id) ALTER TABLE MyTable     DROP CONSTRAINT UQ_TableX CREATE NONCLUSTERED INDEX IX_MyTable_FamilyName ON MyTable(FamilyName) This solves it :) p.s. it takes some time to drop an...

Single Responsibility Principle

"The simplest way to do something is usually the best" Have fun, Elad Shalom, CTO at ITweetLive.com