basic t-sql commands

-- add primary key to a table
ALTER TABLE Karar ADD CONSTRAINT
PK_Karar PRIMARY KEY NONCLUSTERED
(
KararId
) ON [PRIMARY]
GO

-- change data type of a column
alter table Products
alter column ProductName varchar(250)

Supression of Click Sound on WebBrowser Navigate

Open the Sounds and Multimedia Control Panel applet (go to Start, Settings, Control Panel, and double-click Sounds and Multimedia).
Select the Sounds tab.
Under Sound Events, navigate to the Internet Explorer section.
Navigate to Start Navigation and remove the sound for this event by selecting "none."
Click OK.

OR

Start the registry editor (e.g., regedit.exe).
Navigate to the HKEY_CURRENT_USER\AppEvents\Schemes\Apps\Explorer\Navigating subkey.
Select the .current subkey.
Select Delete from the Edit menu.
Click Yes in the confirmation dialog box.

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/e72b37d2-d20b-4a59-8560-24a10b17db97/

bir tablo uzerinden iliskili diger tabloyu guncelleme

UPDATE TABLE1
SET Column1 = (SELECT TABLE2.Column1
     FROM TABLE2
WHERE TABLE2.IDColumn = TABLE1.IDColumn)

update yayin
set ukod = s.ukod
     from yayin y, sayfa1$ s
where s.yayinno = y.yayinno

bir tablonun id alanina deger atamak

DECLARE @ID decimal
SET @ID = 0

DECLARE #cursor CURSOR FOR
(SELECT _ID FROM _TABLE)

OPEN #cursor
FETCH NEXT FROM #cursor

WHILE @@FETCH_STATUS = 0
BEGIN
UPDATE _TABLE
SET _ID = @ID + 1
WHERE CURRENT OF #cursor
SET @ID = @ID + 1
FETCH NEXT FROM #cursor
END

CLOSE #cursor
DEALLOCATE #cursor

sql server full-text search


sorun:
SQL Server encountered error 0x80070218 while communicating with full-text filter daemon host (FDHost) process. Make sure that the FDHost process is running. To re-start the FDHost process, run the sp_fulltext_service 'restart_all_fdhosts' command or restart the SQL Server instance.


çözüm:
EXEC sp_fulltext_service 'restart_all_fdhosts'


sorun devam ediyorsa:
sql server configuration manager --> sql full-text filter daemon launcher
çalıştığından emin ol.


sorun devam ediyorsa:
sql server configuration manager --> sql full-text filter daemon launcher
log on as değerinin sql server'ınki ile aynı olduğundan (local system, local service, network service) emin ol.


tabloya full-text index tanımlama:
tabloya sağ tık --> full-text index --> define full-text index...


full-text index kullanarak arama yapma:
select *
from Mevzuat
where contains (MevzuatAdi, 'YERALTI or DEVLET')



eğer query sonuç döndürmüyorsa:
full-text index'i silip yeniden yarat.

not: query'nin ilk çalışması yavaş olabilir. diğer çalışmalar hızlı olacaktır.

The backup set holds a backup of a database other than the existing database

RESTORE DATABASE yourdatabasename
FROM DISK = N'C:\yourbackupfilename'
WITH REPLACE

redirect page after embedded youtube video ends

<script type='text/javascript' src='swfobject.js'></script>

<div id='mediaspace'>
This video requires Javascript and Flash</div>

<script type='text/javascript'>
var player = null;
function playerReady(thePlayer) {
player = document.getElementsByName('ply')[0];
addListeners();
}
function stateMonitor(obj) {
if (obj.newstate == 'COMPLETED') {
// load a new page
window.location = 'http://www.google.com';
}
};
function addListeners() {
if (player) { player.addModelListener("STATE", "stateMonitor"); }
else { setTimeout("addListeners()", 100); }
}
// var s1 = new SWFObject('player-viral.swf', 'ply', '470', '320', '9', '#ffffff');
// s1.addParam('allowfullscreen', 'false');
// s1.addParam('allowscriptaccess', 'always');
// s1.addParam('flashvars', 'file=http://www.youtube.com/v/SXg1qpUiY7Y&autostart=true');
// s1.write('mediaspace');
</script>

<object id="thePlayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="ply" width="400" height="315">
<param name="movie" value="player-viral.swf" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="file=video.flv&image=preview.jpg" />
<embed
type="application/x-shockwave-flash"
id="player2"
name="player2"
src="player-viral.swf"
width="400"
height="315"
allowscriptaccess="always"
allowfullscreen="true"
flashvars="file=<%= VideoPath %>&image=preview.jpg&autostart=true"
/>
</object>

http://www.warriorforum.com/programming-talk/35546-redirect-another-url-after-embedded-youtube-video-ends-possible.html

enable remote connection on sql server 2008

http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/

the trick is to enable tcp/ip protocol:

- On the left window, expand SQL Server Network Configuration -> Protocols for SQLEXPRESS. You see that TCP/IP protocol status is disabled.

- Right-click on TCP/IP and select Enable to enable the protocol.

html parser

http://htmlagilitypack.codeplex.com/

extension methods in linq

public static class MyExtensions
{
    public static IEnumerable SelectWhere(
     this IEnumerable source,
     Func filter)
    {
        var results = new List();

        foreach (var s in source)
            if (filter(s))
                results.Add(s);

        return results;
    }
}


    private double? GetConvertedPrice(RealEstate realEstate)
    {
        return realEstate.Price * exchangeRates[realEstate.PriceCurrencyId.Value - 1].Value;
    }




        var realEstates = _db.RealEstates.SelectWhere(re =>
                                                       (re.CategoryId == null || catId == null || re.CategoryId == catId)
                                                       && (re.TypeId == null || typeId == null || re.TypeId == typeId)
                                                       && (re.CityId == null || cityId == null || re.CityId == cityId)
                                                       && (re.DistrictId == null || districtId == null || re.DistrictId == districtId)
                                                       && (re.Price == null || priceMin == null || GetConvertedPrice(re) >= priceMin)
                                                       && (re.Price == null || priceMax == null || GetConvertedPrice(re) <= priceMax)
            );


http://msdn.microsoft.com/en-us/library/bb383977.aspx

search this blog (most likely not here)