Skip to main content

Posts

Force Application update in ClickOnce deployment

the key is to set minimum requirement version to be exactly like the one u published right now to remove the update popup dialog when starting clickonce program just make sure the version is the same between Publish version and Update the Project properties - Publish until then

WCF: The underlying connection was closed

hi, just got an error for couple of days when try to return a model contain child record using Entity Framework and DBContext i have this Role class that contain list of User within that Role so when i try to get specific Role along with the User it give me an error "The underlying connection was closed " after searching alot i came up with this great solution disabled proxy creation and lazy loading or  manually in Entity DBContext constructor it run succesfully and can return UserInRole but if i filled up the table then the error comes, so we need to  Preserving Object Reference in WCF  but i came with this very useful  Andrey Chabster Blog  that using custom attribute that needed for the Service contract and Operation contract  until then

The version of SQL Server in use does not support datatype datetime2

hi again,  just came up with this error in Entity Framework  the reason is because my development using SQL2008 express edition but the preproduction using SQL2005 and the solution is fairly simple  Open your EDMX in a file editor (or “open with…” in Visual Studio and select XML Editor). At the top you will find the storage model and it has an attribute ProviderManifestToken. This has should have the value 2008. Change that to 2005, recompile and everything works after trying up for 2 hours :D until then

Renaming SQL Server Default Instance

hi all, found another intresting stuff to post scenario: u change windows computer name and suddenly the query that contains SQL Server link server or anything that currently connect to ur "changed computer" is not working try using this query in SSMS -– Get the current name of the SQL Server instance for later comparison. SELECT @@servername –- Remove server from the list of known remote and linked servers on the local instance of SQL Server. EXEC master.dbo.sp_dropserver ‘[SERVER NAME]‘ –- Define the name of the local instance of SQL Server. EXEC master.dbo.sp_addserver ‘[NEW SERVER NAME]‘, ‘local’ –- Get the new name of the SQL Server instance for comparison. SELECT @@servername after try, u must restart sql server services...then check if the query is working now see u

Get Child and Parent from hierarchy Table using Common Table Expression (CTE) - SQL 2005 and above

hi, just want to post something that might be useful DECLARE @a AS TABLE ( autoid INT  , name VARCHAR(20) , parentid INT ) INSERT INTO @a (autoid, name, parentid) SELECT 1, '1', 0 UNION ALL SELECT 2, '1.1', 1 UNION ALL SELECT 3, '1.2', 1 UNION ALL SELECT 4, '1.2.1', 3 UNION ALL SELECT 5, '2.1', 2 UNION ALL SELECT 6, '3.1', 3 UNION ALL SELECT 7, '3.2', 3 /* 1 1 0 2 1.1 1 3 1.2 1 4 1.2.1 3 5 2.1 2 6 3.1 3 7 3.2 3 */ /* Get Parent Records from child '1.2.1' return: 1.2 (parent from '1.2.1') 1 (parent from '1.2') */ ;WITH    employeeMaster       AS ( SELECT   p.autoid ,                     p.parentid ,                     p.[name]            FROM     @a p            WHERE ...

Find size of SQL Server tables and other objects with stored procedure

my colleague needs a query to seek for all tables in certain Database then use it to display informati on such as: Created Date, Rows in that tables, etc at first i look over sp_spaceused but it end up wrapping query which is hard because undocumented and it failed :( also considerations can be used for SQL 2000 so i google it and found this link , it works for SQL 2000 and above i tweak a bit to meet my requirement but credit goes to  Richard Ding here is the query that i used USE master; GO IF OBJECT_ID(N'dbo.sp_SOS', N'P') IS NOT NULL   DROP PROCEDURE dbo.sp_SOS; GO CREATE PROCEDURE dbo.sp_SOS   @DbName sysname = NULL,   @SchemaName sysname = NULL,   @ObjectName sysname = N'%',   @TopClause nvarchar(20) = NULL,   @ObjectType nvarchar(50) = NULL,   @ShowInternalTable nvarchar(3) = NULL,   @OrderBy nvarchar(100) = NULL,   @UpdateUsage bit = 0 AS /*=============================================================...