Archive for the ‘SQL Server’ Category
if you Wanted to create temporary tables without create and all stuff.
Select * into #TEMPTABLENAME from TABLE
Microsoft.Practices.ServiceLocation.ActivationException–EnterpriseLibrary The type Database cannot be constructed
While moving code first time to live server, we started to get following error. I found that the issue in my case is, I do not put providerName="System.Data.SqlClient" in following connection string.
<add name="XYZ" connectionString="Data Source=localhost;Initial Catalog=LondonDreams;Persist Security Info=True;User ID=dream;Password=dream" providerName="System.Data.SqlClient"/>
Once I put that in above part, it worked fine for below error.
Microsoft.Practices.ServiceLocation.ActivationException: Activation error occured while trying to get instance of type Database, key "XYZ"
—> Microsoft.Practices.Unity.ResolutionFailedException: Resolution of
—> the dependency failed, type =
"Microsoft.Practices.EnterpriseLibrary.Data.Database", name = "XYZ".
Exception occurred while: while resolving.
Exception is: InvalidOperationException – The type Database cannot be constructed. You must configure the container to supply this value.
At the time of the exception, the container was:
—> System.InvalidOperationException: The type Database cannot be constructed. You must configure the container to supply this value.
For resolution to this specific error.
You need to install first SQL Server 2005 on blank machine. Install SP3.
Now, goto Binn directory of installation, take both the file mentioned in KB and keep it.
Now, start installation on the machine and when error occurs, dont quit. On dialog of retry, just overwrite both the file on Binn directory and then retry. It works for me.
If you dont have two PC, i think you should install blank SQL Server SP3 and copy the files.
If you directly use convert it gives you solution in terms of +e. But if we convert it to bigint first then it provide the correct conversion to string.
CONVERT(nvarchar, CAST(floattoconvert as bigint))
You can use str function but you need to be careful as it appends 0 or space while converting the same. So it would be bit tricky to use str function.
To resolve this error:
1. Open the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet
2. Rename the value DependOnService to anything
3. Restart the server
Whenever we specify / in the DateTime format, it shows and convert the DateTime Separator that is setup in your regional settings.
so DateTime.Now.Date.ToString(@"d/MM/yyyy") will display “3-06-2010” on my pc as my regional setting has “–” as datetime separator.
If you require / in the date (or if you need any char as it is without converting it to Format specified in DateTime) then you need to add escape char before the char you require.
And that is the reason, DateTime.Now.Date.ToString(@"d\/MM\/yyyy") will give you “3/06/2010”
🙂 Happy ProgRaMMing