Friday, September 9, 2011

Fancy box and mvc's action result

Hi,

I faced issue with asp.net mvc. The images
I'm using are stored in a database. They are served from the server
using ASP.NET MVC 3. Therefore, my image links look like this:
<a href="/Photo/Image/4" rel="gallery"><img src="/Photo/Image/4"
alt="foo" /></a>

The fancybox script uses regex to determine if the link is an image.
Well, it fails on this, and winds up showing you the raw data in the
image file. I figured out what to do by reading the javascript. All I
needed to do was add 'type': 'image' to my options. My script looks
like this:
$(".gallery a").fancybox({
'zoomSpeedIn': 300,
'hideOnContentClick': true,
'zoomSpeedOut': 300,
'overlayOpacity': .8,
'type': 'image'
});

JQuery Fancy box

http://fancybox.net/

Wednesday, September 7, 2011

Check no of open connection in SQL server

--> To allow users to view current activity on the database:
sp_who2

--> To give you the total number of connections per database on a database server:

SELECT DB_NAME(dbid) as 'Database Name',
COUNT(dbid) as 'Total Connections'
FROM master.dbo.sysprocesses WITH (nolock)
WHERE dbid > 0
GROUP BY dbid

--> To get the dbid from database name
SELECT DB_ID('MyDBName') as [Database ID]

--> To give you the process Ids of existing connections in the database (not necessarily open but existing):
SELECT spid
FROM master.dbo.sysprocesses WITH (nolock)
WHERE dbid = (SELECT DB_ID('MyDBName') as [Database ID])

--> To give you information about the actual process id (replace 1018 with the spid):
dbcc inputbuffer (1018)

--> To kill a process
kill 1018

Friday, August 26, 2011

TCP/IP Application

Below is link for sample application

http://www.dijksterhuis.org/building-a-tcpip-server-using-c/

It will give you amazing startup code in TCP/IP Communication.

If you are able to connect to the local machine via telnet command not able to connect from another machine then make sure to add exe and port into exception.

Friday, July 8, 2011

Temp table insert with sp_executesql

DECLARE @jobs TABLE
( jobcount int
)
INSERT
INTO @jobs
EXEC
sp_executesql
N’select 1 AS jobcount’
SELECT
*
FROM @jobs

Tuesday, July 5, 2011

How to recover suspect SQL server 2008 Database

DBCC CHECKDB (’YourDBname’) WITH NO_INFOMSGS, ALL_ERRORMSGS

Then run below query

EXEC sp_resetstatus ‘yourDBname’;
ALTER DATABASE yourDBname SET EMERGENCY
DBCC checkdb(’yourDBname’)
ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB (’yourDBname’, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE yourDBname SET MULTI_USER

Tuesday, June 21, 2011

SC command - Access denied

http://kevin.vanzonneveld.net/techblog/article/allow_windows_users_to_restart_service/