Thursday, July 30, 2015

Cannot convert null to 'bool' because it is a non-nullable value type

I got following error: Exception Details: Microsoft.CSharp.
RuntimeBinder.RuntimeBinderException: Cannot convert null to 'bool' because it is a non-nullable value type, today while referencing a .dll file and creating object of a class.

I could hardly solve the issue by just looking into the stack trace. But I could back trace the changes I had made and point out the spot it occurred at. I found that it was caused by improper passing of null object where constructor of my repository class expected object. Some hit and trail got me out of the issue. Please write in the comments if you have faced the exceptions and solved it.

Thank you.

Wednesday, July 29, 2015

Convert datetime to MMDDYY format in sql server

If you ever needed to convert datetime field to MMDDYY format in sql server, read on. I am going to present you a quick tips on how to get date or datetime field in sql server in MMDDYY format. Let's do it step by step.

First of all I would like to remind you to learn how to convert date to different date string using Convert function of ms sql server. This will prepare background for the technique used in this article.

For the sake of easiness, I will use current date and time as the date field we would like to convert to MMDDYY format. As you all know, getdate() returns you current date and time, as below:

select getdate() as Today
Output is: 2015/07/29 05:00:47.563

First we will get this date in mm/dd/yyyy format. Here is how:
select convert(varchar(10),getdate(),1)
Output is: 07/29/15

Now we are almost there! Let replace those forward slashes (/) with empty string. And voila! We have MMDDYY. Here is the script:

select replace(convert(varchar(10),getdate(),1),'/','')
Output is: 072915

All the steps are put together below.
















Now we have successfully converted datetime field in sql server into MMDDYY format.

Thursday, March 14, 2013

Object Relational Database Features Implemented with Oracle

Oracle is a modern and feature-full database that supports many features of an object relational database system. Oracle supports type definition, type inheritance, collection type, member function, nested table, association and aggregation relationships. In this article, I have implemented all features other than association and aggregation relationships.

1. Database Structure
I have considered a database for a simple ecommerce site. The database will consist of different type of products having a bunch of attributes inherited from Products table whereas each table will have some other attributes of its own. So here I have a product object and a Clothes table that inherits the product object. Each clothe is available in multiple sizes. Further, each clothe tuple is available in multiple colors represented by a collection array in this example. For simplicity, I have included only one such table that inherits from products table where there could be other tables like Jewellery, Bags, Cosmetics and so on. Further, each product has multiple categories which is implemented by a nested category table. In our example, we charger 10% extra on the price of each product. Hence I have used a member function that returns 10% extra of the price.

2. Object Relational Structure
Product is an object, not the table, from which another object or type ClotheType is inherited. Product also contains a nested table Category so that each product row contains a reference to an instance of the table Category. Finally we create a table Clothes of the type ClotheType. ClotheType consists of two attributes: clothesize and clothecolor where clothesize is another Type and clothecolor is a collection array.

The object oriented concept of function has been included in ClotheType object which we call member function in Oracle.

3. DDL Script for the Database Objects

Create a type CategoryType
Create or replace type CategoryType as object(
categoryid int,
categoryname varchar2(50)
) not final

Create a table of CategoryType
Create or replace type ProductCategory as Table of CategoryType

Create an inheritable (specified by "not final" construct) object Product
Create or replace type Product as object(
productid int,
productname varchar2(100),
price number(7,2)
) not final

Create type ProductSize
Create or replace type ProductSize as object(
sizecode varchar2(20),
sizevalue varchar2(20)
)

Create collection array for colors
create or replace type ColorArray as varray(20) of varchar2(20)

Create a type ClotheType that inherits from Product
Create or replace type ClotheType under Products(
clothesize productsize,
clothecolor colorarray,
clothecategory productcategory,
member function total_price return number
)

--define the body for the member function total_price
create or replace type body ClotheType as
 member function  total_price return number is
 begin
                 return (price + price * 0.1);  
 end;
end;

Finally create a table of the type ClotheType
create or replace table Clothes of clothetype
nested table clothecategory store as prod_cat

4. Inserting rows into the Clothes table
Now we insert rows into the Clothes table.
  
   insert into clothes
   values(3,'V-neck tshirts with full sleeve',250,
   productsize('M','Medium'),
   colorarray('White','Blue','Black'),
          productcategory(categorytype('1','T-Shirts'),
                     categorytype('2','Men''s Wears')
   )
      );
   
   insert into clothes
   values(2,'Round-neck tshirts',450,
   productsize('L','Large'),colorarray('Red','Black','Green'),
          productcategory(categorytype('1','T-Shirts'),
                     categorytype('2','Men''s Wears')
      )
      );
     
   insert into clothes
   values(1,'Both side design tshirts',600,
   productsize('S','Small'),colorarray('Red','Blue','Black'),
             productcategory(categorytype('1','T-Shirts'),
                     categorytype('2','Men''s Wears')
      )
      );    
5. Querying the table Clothes
a. Normal query to select the columns productid, productname, pirce and productsize's columns sizecode and sizevalue

select c.productid,c.productname,c.price,
 c.clothesize.sizecode,c.clothesize.sizevalue
from clothes c

select from a table in object relational database Oracle


b. Querying the categories in a product from the nested table clothecategory

select c.productid,c.productname,p.categoryid,p.categoryname
 from clothes c,table(c.clothecategory) p
where c.productid=1;

select c.productid,c.productname,p.categoryid,p.categoryname
 from clothes c,table(c.clothecategory) p
where c.productid=2;

select from nested table in object relational database Oracle


c. Querying the colors associated with a product

select c.productid, c.productname,p.*
 from clothes c, table(c.clothecolor) p
where c.productid=2;

select from collection array in object relational database Oracle


d. Querying the total price by calling the member function total_price

select p.productid, p.productname,p.price,p.total_price() "Total Price"
 from clothes p;

select using member function in object relational database Oracle


6.Conclusion
we realized and implemented a bunch of object relational features of Oracle database. Some of the features we worked with were type inheritance, type as a column, datatype collection and nested table, as well as member function. We developed DDL script to create such objects and performed select queries. All in all, we got the good glimspe of object oriented programming in Oralce database.

Tuesday, February 19, 2013

Add clickable rows in csharp DataTable and bind to asp.net gridview

Responding to a good demand from a lot of readers, I have now presented a way to create DataTable programmatically where rows accept html and hence they can be made clickable. Complementing to my previous post on creating DataTable programmatically in asp.net, this tips will bind DataTable to an asp.net GridView where one of the columns in each row contains clickable html anchor.

Below is the code snippet in C#.

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //get data from programmatically created DataTable and bind to GridView
            gvTable.DataSource = CreateTable();
            gvTable.DataBind();
        }
    }


//Create DataTable programmatically
    //In this example, there are three columns
    //namely ID, WebsiteName and URL
    private DataTable CreateTable()
    {
        //create datatable
        DataTable table = new DataTable("Websites");
        
        //add columns to the table
        table.Columns.Add("ID", typeof(int));
        table.Columns.Add("WebsiteName", typeof(string));
        table.Columns.Add("URL", typeof(string));
        //add as many rows as you want
        AddNewRow(1, "dotnetspidor", "http://dotnetspidor.blogspot.com", table);
        AddNewRow(1, "asp.net", "http://asp.net", table);
        AddNewRow(1, "codeplex", "http://codeplex.com", table);
        return table;
    }


//Add new row to a table
    private void AddNewRow(int id,string website, string url,DataTable table)
    {
        DataRow row = table.NewRow();
        row["ID"] = id;
        row["WebsiteName"] = website;
        //get url from GetURL method
        string link = GetURL(website, url);
        row["URL"] = HttpUtility.HtmlDecode(link);
        table.Rows.Add(row);
    }


//create html anchor from website name and it's url
    private string GetURL(string website, string url)
    { 
        return "<a href=\""+url+"\">"+website+"</a>";
    }

Here goes the design code for the GridView. Please note the property HtmlEncode="false" in the third BoundField. This prevents the GridView from rendering encoded html so we retain the html code from our DataTable column.

    <asp:gridview autogeneratecolumns="false" id="gvTable" runat="server" width="500px">  
<columns>
<asp:boundfield datafield="ID" headertext="ID">
<asp:boundfield datafield="WebsiteName" headertext="Website">
<asp:boundfield datafield="URL" headertext="URL" htmlencode="false">
</asp:boundfield></asp:boundfield></asp:boundfield></columns>
</asp:gridview>

The output looks like below.
Fig: Output of programmatically generated DataTable in a gridview - with clickable row
Happy Programming!!
Shout it

Saturday, February 9, 2013

Strip html tags and extract subset of string from text using regular expression in c-sharp

Today I am presenting a quick tips on how to strip html from text using regular expression (with Regex class) in C#. In a scenario like presenting a blurb or summary of certain characters we may need to remove html tags from a html string (of news details, article details etc.). I have following function in my Helper library for the very problem.


    /// 
    /// Strip out html tags from text
    /// 
    /// Source string
    /// 
    public static string StripTagsFromHtml(string source)
    {
        return Regex.Replace(source, "<.*?>", string.Empty);
    }


To extract a number of characters from the source string, we can extend the function as following.

    /// 
    /// Strip out html tags from text and return extract from it
    /// 
    /// Source string
    /// Number of characters to extract
    /// 
    public static string StripTagsFromHtml(string source, int characterCount)
    {
        string stripped = Regex.Replace(source, "<.*?>", string.Empty);
        if (stripped.Length <= characterCount)
            return stripped;
        else
            return stripped.Substring(0, characterCount);
    }

Happy programming!

Shout it

Saturday, January 19, 2013

Learning Java - I am using Eclipse IDE

For a long time, I have remained asp.net web application developer. But as you prepare to bear the role of an academician also, how could you stick to only one programming framework or programming language? Yes, that has come to my life also. And I have growing appetite for learning more programming languages.

JAVA undoubtedly brought about revolutions in so many fields. Oracle proudly declares that millions of devices run with JAVA. The academic world loves C, C++ and JAVA equally for the ongoing researches in so may fields of science and engineering.

To get my hands dirty with the first few programs in JAVA, I downloaded eclipse - the most popular Integrated Development Environment (IDE) for JAVA. I hope to come up with some samples soon.

For now, to elaborate "why java?", an excerpt from java site:

Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices. 

Happy programming!

Friday, May 18, 2012

Read hidden field value in asp.net from jquery

Often we are confused about how to read values set in asp.net HiddenField from jquery and use the values in the web form. Many-a-times we see the threads over the asp.net forums about the difficulties associated with reading asp.net HiddenField values. I have tried to give easy and fast way to read values and set values of hidden filed in asp.net using jquery.
You may first download the latest jquery file from jquery.com.
asp.net webform - design page
<body>
    <form id=\"form1\" runat=\"server\">
    <div>
    <asp:HiddenField ID=\"HiddenField1\" runat=\"server\" />
    <asp:Label ID=\"lblSiteName\" runat=\"server\"></asp:Label>
    </div>
    </form>
    <script type=\"text/javascript\" src=\"js/jquery-1.3.2.min.js\"></script>
    <script type=\"text/javascript\">
        $(function () {
            //reading hidden field value
            var mySite = $(\'#HiddenField1\').val();
            //displaying the value in an asp.net Label control
            $(\'#lblSiteName\').html(\'My site is: \' + mySite);
            //setting value of HiddenField control
            $(\'#HiddenField1\').val(\'New site is: http://asp.net\')
        });
    </script>
</body>
asp.net webform - code page (in c#)
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HiddenField1.Value = "http://dotnetspidor.blogspot.com";
        }
    }
Known issue
If you have put the asp.net HiddenField control below the script tags, you may end up reading 'undefined' values. To solve the issue, I recommend putting the hidden fields at the top of the page just below the form tag.
Further, if you are using asp.net Master Page, please make changes in the jquery codes respectively. In such case, I  recommend the following syntax:
var mySite=$('[id$=HiddenField1]').val();
The system $= means the value that end with HiddenField1. This works since you usually see the id HiddenFiled1 used with master page rendered as ctl00_ContentPlaceholder1_HiddenField1.

Happy programming!!
Shout it

Friday, April 27, 2012

Expecting non-empty string for 'providerInvariantName' parameter - database connection error in asp.net web application

Just a simple accidental error in asp.net web application's web.config file, and you see the following error:

Expecting non-empty string for 'providerInvariantName' parameter. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Expecting non-empty string for 'providerInvariantName' parameter.
Fig. 1 Error page showing providerInvariantName parameter error for asp.net web application's database connection error
 The error occurred only because I had missed the providerName property in my connection string.
My connection string is:
<connectionStrings>
  <add name="ConnectionString" connectionString="data source=my-pc;Integrated Security=true;Initial Catalog=mydbname"
   providerName="System.Data.SqlClient" />
  </connectionStrings>
And accidentally it was broken like:
<connectionStrings>
  <add name="ConnectionString" connectionString="data source=my-pc;Integrated Security=true;Initial Catalog=mydbname" />
  </connectionStrings>
I was stunned to get the error when I had just finished uploading the web application to my host. After some googling, I found the cause and fixed the error. It worked. Happy programming!

Friday, April 20, 2012

Flexible jquery based modal box or popup box -ColorBox

I have been using the jquery plugins for long. Many times I do need to implement facebook-like photo viewer in gallery pages. Similarly, mostly in admin pages of my asp.net web applications, I frequently us modal pop-ups for various purposes like ajax loading of content, iframe loading from other internal pages, confirmation and error show ups. Typically I used to go for separate plugins for the purpose. Lately I found the ColorBox plugin that satisfies both the needs. In one sense, this is a framework for me. You can visit  ColorBox and explore it.

Lets look at the features the ColorBox jquery plugin possesses.
  • Supports photos, grouping, slideshow, ajax, inline, and iframed content.
  • Lightweight: 10KB of JavaScript (less than 5KBs gzipped).
  • Appearance is controlled through CSS so it can be restyled.
  • Can be extended with callbacks & event-hooks without altering the source files.
  • Completely unobtrusive, options are set in the JS and require no changes to existing HTML.
  • Preloads upcoming images in a photo group.
  • Well vetted. ColorBox is one of the top jQuery plugins.
For jquery 1.3.2+, ColorBox has its older version, whereas for jquery 1.4.3+, ColorBox has its news version.
Meantime, you may also enjoy browsing jquery with asp.net tips in this blog. To sate the appetite of enthusiasts, I have also posted a bunch of javascript with asp.net related tips and tricks which you may find useful in your asp.net web development career. Cheers! kick it on DotNetKicks.com

Thursday, April 12, 2012

Domain without www not working from plesk hosting

I use plesk hosting for my company. An error I got (and shocked with it!) was that my domain was displaying the correct site with :
http://mysitedomain.com
But did not work with:
http://www.mysitedomain.com
Later it was traced that, by default the www was not included while creating the domain.
So if you are creating a domain, don't forget to inlcude www (by checking a checkbox next to www). That will keep yourself away from the worry.
If you have already created the domain and have the problem, you can always go and edit the domain (from the very first page that lists all the domains) and update it to include www.
Cheers!
kick it on DotNetKicks.com

Thursday, March 22, 2012

The database principal owns a schema in the database, and cannot be dropped

While restoring a database backup file in my hosting I was prompted with some error message regarding existing user in the database. So I decided to delete those users. But while trying to delete the users from my local sql sever management studio, error occurred.
The database principal owns a schema in the database, and cannot be dropped.
I tried out browsing the property of the user and removing the assigned scheme from the lists. It was somehow unsucessful. So I decided to go search for the solution and stumbled at doing it the most powerful way - through command.
Here goes the solution - Revoke the database schema assigned to the user and assign it back to the default db object.
ALTER AUTHORIZATION ON SCHEMA :: my_user_name to db_owner
 If you want to assign the schema  to another user, here is how you accomplish it.
 ALTER AUTHORIZATION ON SCHEMA :: my_schema_name to my_user_name
Cheers!
kick it on DotNetKicks.com

Monday, March 5, 2012

Invitation to connect on LinkedIn

 
LinkedIn
 
 
 
sangam uprety
 
From sangam uprety
 
Executive Director at Time Infotech
Nepal
 
 
 

I'd like to add you to my professional network on LinkedIn.

- sangam

 
 
 
 
 
 
You are receiving Invitation to Connect emails. Unsubscribe
© 2012, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA
 

Tuesday, February 7, 2012

Installing sql server 2005 express in windows 7

If you started with sql server 2005 express editions in your windows vista or xp operating systems, you are sure to stumble while installing sql server 2005 express in windows 7. After having long time experience of sql server 2005 express in my windows vista, I just switched to windows 7 and tried same version of express in it. But it is not supported. You get the failure message sort of:
This software is not supported in this version of operating system.
The simple solution is to acquire SQL Server 2005 Express Service Pack 3. Choose 32 bit or 64 bit version according to your machine.

The story does not finish yet. If you are looking for sql server management studio express, you again have to look for service pack 3 of sql server 2005 management studio. Get SQL Server 2005 Management Studio Express Service Pack 3 and get installed in your machine. Still don't forget to choose right version matching to your machine (32 or 64 bit).

Happy upcoming Valentine's Day!


Friday, December 30, 2011

Prove that programmers too can be social change makers : last day to vote for a social work

A dream to provide solar and computer to a school in rural Nepal! It can be realized by your single vote. Please vote for it at Solar and Computers to a School in Rural Nepal

Appeal from the dreamer - read below please.
My dream is to help a school in an extremely remote village of Western Nepal to buy and install a solar system, batteries, inverters, computers and printers necessary for the school for its computer lab and e-library. The school was built with support from local people and some of the colleges and students of Kathmandu.

Lalu village where the school is located lacks basic infrastructure, however with the local people driving it, the school is a vehicle to bring the community into the 21st century.

The school has very innovative ideas that make it unique. Firstly, Modern Model Residential School is a rural based purely service oriented co-educational English medium primary institution registered as Non-profit Distributing Company. Secondly, it strives to be a progressive institution that acts as a hub for the community, imparting education mixed with modern technology.

Using a pro-rata system the school is able to provide quality education to people of the entire community. Orphaned, disadvantaged or disabled students and families are admitted free of charge, whilst others contribute as little as $3 per month. This shows how even a small amount can change not only the students’ lives but their families and the entire community.

Kalikot is amongst one of the world's most impoverished areas. “57% of people in Kalikot district live under extreme poverty. Per capita income lies at Rs. 6000 (around $ 83) per year and average life expectancy remains at just 42. Only 57.27% of children are literate where as overall literacy rate is at just 38.47%. Still 45.95% of children involve in some kinds of economic activity instead of going to school.” -Central Bureau of Statistics of Nepal, District Profile, Kalikot 2008 AD .
Please don't forget that your single click can make it happen. Time is too short to stop and think. Help to realize the dream and be proud of it! Click Solar and Computers to a School in Rural Nepal to vote!

Yes, programmers too can be social workers!

Thank you!

Tuesday, December 27, 2011

CamStudio - Free Streaming Video Desktop Recording Software

CamStudio a really useful desktop based software that you can use for recording anything that happens with your desktop. And the best part is it is distributed under GNU General Public License (GPL) license. Free to use for both commercial and non-commercial uses. So what are the uses? Let me recite the site itself:
CamStudio is able to record all screen and audio activity on your computer and create industry-standard AVI video files and using its built-in SWF Producer can turn those AVIs into lean, mean, bandwidth-friendly Streaming Flash videos (SWFs) Here are just a few ways you can use this software: You can use it to create demonstration videos for any software program Or how about creating a set of videos answering your most frequently asked questions? You can create video tutorials for school or college class You can use it to record a recurring problem with your computer so you can show technical support people You can use it to create video-based information products you can sell You can even use it to record new tricks and techniques you discover on your favourite software program, before you forget them
How to get the software? How to use this? Yes, it is very easy. Watch the video on how to capture video from your desktop and you are easy to begin! Why this post? Any open source products like this one is a great contribution to the whole world. So this just a give-back to the great effort. I have just tried to spread the word. Could you please do the same? Thank you!

Tuesday, November 22, 2011

Working with dropdownlist or combobox using jquery

More often programmers need to work with dropdownlist or combobox using jquery. We need to manipulate the dropdownlist options using jquery scripting. And it is the case that almost always we don't remember how to implement jquery selector. And for all of my readers, who are enthusiastic programmers and/or designers, and for myself, I am discussing in this post the actions with jquery to manipulate asp.net dropdownlist options.




Now append another option using jquery.
$('[id$=ddlTest]').append('');
[Why am I using the selector syntax $('[id$=ddlTest]') instead of $('#ddlTest')? We use #ControlID to select a control with specified id. $= means 'select a control whose id ends with specified value. If you are using master page, the rendered id of the dropdownlist is preceded with some text.] Now get the selected value from the dropdownlist.
var selVal=$('[id$=ddlTest]').val();
Now get the selected texct from the dropdownlist.
var selTxt=$('[id$=ddlTest] option:selected').text();
Now, select a value programmatically.
var selTxt=$('[id$=ddlTest]').val('Nepal');
And I hope you are comfortable with detecting through jquery when the use selects an item. Good luck!kick it on DotNetKicks.com

Tuesday, October 18, 2011

Missing File menu in visual studio 2010

I just got irritated to see the file menu in visual studio 2010 missing. All other items of the menu, e.g. Edit, View, Refactor, Project, Build etc. were showing. Only mischievous was the File item. It would be of no value for me if only I could add new project in an existing project. But I couldn't find any such option. I had to workout to recover my lost menu item back. And the way is as discussed below.
1. Run Visual Studio Command Prompt for VS2010 as Administrator 2. Navigate to C:\Program Files\Microsoft Visual Studio 10.0\Common 7 3. Run devenv with the option /ResetSettings 4. Press enter This will reset the default settings for the visual studio and open it. Now you see the missing File item. Thanks.

Thursday, September 29, 2011

Disable button in asp net web page to prevent multiple clicks


When a user clicks a button and the response is slow, there are chances that user may click the button again. The scenario may occur both when the button postbacks synchronously or asynchronously. This type of multiple clicks could be prevented if we could just disable the button just after the first click and enable it again when the processing is done. This is quite easy to implement the task in both the cases: synchronous and asynchronous postbacks.
Before we jump on the topic, you may learn how to click a button on enter key press in an asp.net textbox control. Similarly you may be interested in displaying google search-like watermark in an asp.net textbox control. Both the tutorials help you work with asp.net button control more interactively.
Fig. 1: Just after clicking asp.net button

Fig. 2: After postback occurs

If you are using ajax processing on button click, just disable the button when it is clicked and enable it when the ajax processing is done. If you are using full postback on button click, you may just make the button invisible using client-side-scripting when the click occurs. And you don't need to worry about making it visible since after postback the page will be rendered again, with the button visible as usual. In the snippet below I have shown how to 'disable' (in fact disabling won't work since the server side event is not firing) the asp.net button from client side when it is clicked. 
1. Add reference to jquery file

2. Design the web form
   
                           
   
   
3. Write the client scripting function with jquery

4. The code-behind.
protected void Button1_Click(object sender, EventArgs e)
    {
        lblMsg.Text +="Current time : "+ DateTime.Now.ToLongTimeString()+"
";
    }

That's all. When you click the button you catch the client side click event and make the button just invisible. Meantime show 'processing' or similar message. If you love ajax loading image, generate one and show it. From codebehind I have just displayed current time in a label.
Happy Bijaya Dashami (Dashain - the greatest festival of Hindus)!
kick it on DotNetKicks.com

Monday, September 26, 2011

Exclusive access could not be obtained because database is in use-sql server restore database error

While publishing a website to the web server, I took backup of my database. Now I had abc.backup at my hand. Next step was to create a database in the sql server of my host. I did it. Then I uploaded the backup file to the server. When I tried to restore the database I got following error:
Exclusive access could not be obtained because the database is in use
This error normally discourages because we wonder what exclusive access is this that we need to successfully restore the database. After searching a while you come to conclusion that the database to which we are restoring our backup is in use by one or some users you have already added. The popular solution is - temporarily isolate the user from the database Easy, if you run this command at your server:
Use master
go

Alter Database mydbname
SET SINGLE_USER With ROLLBACK IMMEDIATE

 RESTORE DATABASE mydbname
 FROM DISK = 'C:\abc.bak'
Now you are right if you suspect whether we should the roll back to multi user. Yes this way:
Use master;
go

ALTER DATABASE mydbname

SET MULTI_USER;
go
Note that we run the commands against the master database, not the candidate database itself. And did I do the same last time? Nope. I was just happening with a slight mistake. I had created users for the db before I restored the database. So to save yourself from all those stuffs explained above, just create the database in the server, restore your backup file to it and only then create the database users. Done! Thanks.kick it on DotNetKicks.com

Thursday, September 22, 2011

There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined

Last time I got the following error:
HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.
See in the image below the following config error, and also watch the config source.
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
Root of the error
I got the error when I was deploying a web application precompiled in asp.net 2.0 onto the production server with asp.net 4.0. The simple search reveals that it is known issues with VS 2010 and asp.net 2.0. But my site is asp.net 2.0 enabled. What's the root of the error then?  
My conclusion (and please correct me if necessary) I have configured asp.net web extension namespaces in my web.config file. You don't see this in asp.net 3.5 and 4.0 enabled sites since servers with asp,net 3.5/4.0 by default server asp.net ajax services. But asp.net 2.0 has to be ajax enabled by installing asp.net ajax extension 1.0 which you can download from here. Sensed duplicate entry of system.web.extension section group? Yes, don't include the following section group in the config section if your site runs on asp.net 2.0 but published on asp.net 3.5/4.0.
    

    
      
        
Comment out the config section (or remove it if you like), and you are done. Good luck! kick it on DotNetKicks.com

Popular Posts

Recent Articles