Code Project

Link Unit

Friday, June 27, 2008

An attempt to attach an auto-named database for file failed. A database with the same name exists, or specified file cannot be opened, or it is locate

I was implementing the sample given at this site http://www.beansoftware.com/ASP.NET-Tutorials/Web-Parts.aspx and encountered the issue.
An attempt to attach an auto-named database for file c:\.....\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
The solution for which is as follows:
we have to add following few lines to the web.config file as below:

"User Instance=True;"
Once I added this option to the Connection String everything works fine. So the new connectionstrings look like this.

<connectionstrings>
<remove name="LocalSqlServer">
<add name="LocalSqlServer" providername="System.Data.SqlClient" connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=DataDirectory\ASPNETDB.MDF;user instance=true;Integrated Security=True;Initial Catalog=ASPNETDB;">
</connectionstrings>

I hope this helps the visitors.

Tuesday, June 03, 2008

Using DBMS_METADATA.GET_DDL to generate the table script

I was using Oracle 10g where it required to get the Scripts of all the tables.
While searching google I ended up with DBMS_METADATA.GET_DDL

SELECT DBMS_METADATA.GET_DDL ('TABLE',tname)';' FROM tab where tabtype='TABLE'

I hope this help the visitors.

Monday, May 19, 2008

ASP.Net Server Unable to assign port

I was facing this problem(ASP.Net Server Unable to assign port) way back when I started using Visual Studio . After googling around for a while this is what solved the issue for me.
I hope this help you as well.
If you want to assign a fixed port number for debugging, please refer to the following steps:
1. Right click the Project in the Solution Explorer, and then select “Properties” 2. Click “Web” tab. 3. Check “Specific port” instead of “Auto-assign Port”.
If you want to debug with IIS, please follow the first and second steps above, and then check “Use IIS Web Server” instead of “Use Visual Studio Development Server”. Also, click the “Create Virtual Directory” button.
Please note the above steps are based on Web Application project. For the Web Site project, we can fix the port number by following steps:
1. Click the project in Solution Explorer. 2. Open “Properties” panel. 3. Set “Use dynamic ports” property to false and assign a value to "Port number".
You may also like to follow the excellent description given at following link
http://blogs.msdn.com/bradleyb/archive/2005/08/29/457573.aspx
I hope this help you as well.

Tuesday, March 18, 2008

Method Error : 12030

While I was trying to make this sample work
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/CCDWithDB.aspx
The following error appeared
1) Method Error 12030
2) Method Error 12031
3) Method Error 500
How I solved it??
1) Specify [System.Web.Script.Services.ScriptService()] before Class defination in Web Service.
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class CarData : WebService
2) Check the name of method is correct as it is defined in Web Service and specified in Cascadedropdown.
3) Install Fiddler program. http://www.fiddlertool.com/Fiddler2/version.asp . It is an excellent Http Debugger.
Hope this help fellow visitors

Sunday, March 09, 2008

Using SQL Server to get Calendar

I was going through this excellent blog http://blog.sqlauthority.com/ and seen the method used by the author Pinal Dave. I tried to do the same using another method. Hope visitors like it.

Create a sequence Table

Select identity(int,1,1) seq into Numbers from sysobjects s , sysobjects so

declare @d datetime

declare @d1 datetime

Set @d1=getdate()-10

set @d= dateadd(d,-day(@d1) + 1,@d1 )

Select @d
Select Isnull(Convert(varchar(12),Min(Case When datepart(dw,@d+N.seq-1)=1 then @d+N.seq-1 else null end),106),'') Monday,

Isnull(Convert(varchar(12),Min(Case When datepart(dw,@d+N.seq-1)=2 then @d+N.seq-1 else null end),106),'')Tuesday,

Isnull(Convert(varchar(12),Min(Case When datepart(dw,@d+N.seq-1)=3 then @d+N.seq-1 else null end),106),'') Wednesday,

Isnull(Convert(varchar(12),Min(Case When datepart(dw,@d+N.seq-1)=4 then @d+N.seq-1 else null end),106),'') Thursday,

Isnull(Convert(varchar(12),Min(Case When datepart(dw,@d+N.seq-1)=5 then @d+N.seq-1 else null end),106),'') Friday,

Isnull(Convert(varchar(12),Min(Case When datepart(dw,@d+N.seq-1)=6 then @d+N.seq-1 else null end),106),'') Saturday,

Isnull(Convert(varchar(12),Min(Case When datepart(dw,@d+N.seq-1)=7 then @d+N.seq-1 else null end),106),'') Sunday

From Numbers N where seq between 1 and 31 and month(@d+N.seq-1) = month(@d)

Group by DatePart(wk,@d+N.seq-1)


Tuesday, March 04, 2008

Parser Error Message: Could not load file or assembly;System.Web.Extensions

Parser Error Message: Could not load file or assembly;System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35; or one of its dependencies. The system cannot find the file specified.
I was facing this problem ,while installing prototype of a web application . Searched through the net and figured out that Ajax was not installed. following steps solved my issue.
  1. Downloaded the ajax from http://asp.net/ajax/downloads
  2. In the project I added a reference to System.Web.Extensions and System.Web.Extensions.Design

I hope this also helps you.

Saturday, February 16, 2008

Speed Up ASP.Net Implementation

While looking for some documents to speed up the .Net implementation . I found the following
http://www.codegeneration.net/downloads/dotNET_db_gen.pdf