Bytes and Bites of Internet
Archive for November, 2010
Ajax Control Toolkit and IE 9 Runtime Error
Nov 29th
You guys may be thinking that what the hell is wrong with this guy. First he doesn’t write much and even if he write he always cries about errors he get while working on his things !!! Its always he , he and he … with error error and errors only … but fact is no matter how much I try to code well, I frequently get really really weird errors and being my log, I like to keep track of these errors in this blog.
Oki, so another error today. As you might know, I like to taste things before they release. Actually, I like that because it keeps me updated with new stuffs in technology of present time. So keeping that tradition alive, I had installed IE 9 Beta in my machine from few months now. Just today I was working / playing with my code as usual. actually it was an old program that I was rewriting to do some improvement in functionality. So, after making some changes I tried to run the program, but I got something like this as error Microsoft JScript runtime error: Invalid set operation on read-only property.
I tried to f9 the code and at one point it was showing some that it need some files from my AJAX Control toolkit (I was using many controls from AJAX Control toolkit). But I was not getting any idea what it is really missing. It was showing me error that we see when we are using component of AJAX Control Toolkit but not including Toolkit Script manager. But I have already included Toolkit Script manager into program, and that actually made me confused about error.
.NET Framework 4 and Could Not Load Type ‘System.ServiceModel.Activation.HttpModule’ Error …
Nov 28th
So, day before yesterday I was working on some app. And I deployed it on my IIS (v7.5) server. The deployment process went very well without any sort of troubles. But when I tried to run that application from my web browser I got loads of error. And I found that the main error was something like this,
Could Not Load Type ‘System.ServiceModel.Activation.HttpModule’
Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.
Description: An unhandled exception occurred during the execution of the current Web request. Review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.
With little googling, I found that I was not the first victim of this error !!! And after few clicks I finally found the reason and solution for this error.
The Reason: If you have installed IIS AFTER installing .NET Framework 4 (in my case) then it won’t get register with IIS and so when you run the app that is built on .NET v.4 by deploying it won’t work and will give you above mentioned error. And the solution is next.
IDENTITY key is not itself set to be Primary Key or Unique Key ??
Nov 20th
If you have done any sort of development in database you might be familiar with IDENTITY column. It basically gives you a column which increments it self to a given value (aka Seed and Increment). General syntax for IDENTITY is,
IDENTITY [ ( seed , increment ) ]
It is basically a “Plan B” for tables where you can’t find any candidate key. By declaring a column having IDENTITY Key, you can get your self out of dilemma of what to do and how to do when your client want you to have flexibility to add any type of redundant data with still ability to distinguish between different entries !! Or simply to evade many to many (m:n) relations between tables. But as we know, it is not a good practice to simply assign an IDENTITY key and jerry rig the problem, but something we don’t have a choice (do we ever have any ??
) …
Anyways, today’s post is about what the title says. Some people (like one of my friend) think that when we declare an Identity column, it itself becomes Unique key (because the IDENTITY key always generates UNIQUE Numbers) .. and hence it can be used as a FK even though we have not made it Primary Key or even not include UNIQUE keyword in its definition !! I have prepared a little experiment to demonstrate this …
Using Cookie in ASP.NET to store temporary data
Nov 15th
Today’s post is about how we can use Cookie to store data temporarily. While working on one project for frontend application my client told me that they need some sort of functionality so that user somehow can temporarily store some of the form data and can use the same data when they run the application again. And without any hesitation the first thought came in my mind was to use cookie for this purpose.
I have written a simple code to demonstrate the use of HTTPCOOKIE to create cookie and then use the cookie to retrieve information from it. It is a simple two textbox , buttons and a label form. It accepts name (last and first) from user and sets it into cookie and then retrieves it from cookie in event of button click (if present, else it displays message that it has not found any cookie !!)
The backend code is as follows,
Handling NULL DATES in .NET and SQL Server
Nov 13th
I think no matter how solid is your application development skills and application testing skills … the end users always find ways to make your application do things which it not suppose to do and so eventually it crash. Or worse, they can generate inconsistency in your database. Being both as application developer and a dba, I know that both of these things can have serious effects and as a developer you are always required to deal with NULL values, as many (read mostly) users like to skip the required field but the manager always want us to be sure that data is consistent and application works just fine … but I think this happens only in books (specifically in books of database dev.
) … but as we all know, the real world is too harsh..
Okie, now about todays post … as we know, in many forms sometimes users are required to enter date. And in general, every data user feed goes to database. But something these database doesn’t like is NULL values for DATE datatype. So in general you will get an exception when you will leave the field empty that has Date datatype, something like “Format Exception” which basically means that it has some issues with datatype conversion.
I have re-produced the issue in my test machine. I have created a sample table, which has two fields and one of them is of DATE datatype. Then I have created a fronted application in ASP.NET (C#) which has two text fields and two buttons and a label. So in one button, when user click it generates an error because of no logic to handle NULL date. But second button does include a logic to handle NULL value as a date, so it will not throw an exception.
I have given code for this test below (Database + Frontend).
create table test (userName varchar(20),logdate date) go -- create proc -- i have created it 'coz of habit, but you can use incline query as well create proc USP_Test @user varchar(20), @logDt date as insert into test(userName,logdate) values (@user,@logDt) go -- see the final results select * from test
SQL Server 2011 CTP is here !!
Nov 10th
Well, I wouldn’t believed it when I read it on few of my favorite sites like SSC and SQLBlogs … but it is actually here !! MSFT has released CTP for next version of SQL Server Code name “Denali”. From initial reading it looks like the next generation of SQL Server will have more enterprise features likely to concentrate more on large systems. As you know its CTP so it is still in process of changes and we will see many improvements before as final product.
I was actually trying to download the CTP copy, but it looks like server is getting hit hard. So I was getting timeout error at this very moment of writing blog. I hope that I will be able to grab it and make it work by this weekend.
WordPress and Database Connection Error …
Nov 6th
This week, I changed my WP Blog password and DB Password for that blog as well. And I did it using control panel provided by my hosting service provider. It went all well without any sort of error or so. But just today when I was trying to access my blog for some past reference, with my surprise my blog was displaying “HTTP Error 500” aka Internal Server Error for my IE9 which made no sense to me … but then I fired up my Chrome/Firefox and browse my blog it was stating “Database Connection Error” … Which was kind of self explaining … I had messed up with the database connection setup.
And it is all because I assumed that when I change password for my DB of WP in control panel of Host, it automatically configures WP to make it use the newer settings … but I WAS WRONG … it actually doesn’t … changing password for DB at Host only gives access to WP to use that password to connect DB to use, but how will WP know that it has to use new password instead of new password ?? Because if you have setup the self hosting WP blog then you know that.. we store DB connection strings (passwords,DB name, DB Username, DB Server Name) manually !! So, we hard code the password for database as well. And naturally, the password update thing in host doesn’t update password in my configuration file of WP
…