Apr 19th, 2009 by ocvirek.com
You did some testing on your database before deploying it and you created new record and then deleted it right away, but there is a hole in your primary key ID’s now and it shouldn’t be. How to fix that before deploying it to production environment ?
It’s quite easy, just open SQL Server Managment Studio and fix it using this T-SQL:
DECLARE @LastID int
SELECT @LastID = MAX(ID) FROM MyTable
DBCC CHECKIDENT (’MyTable‘, RESEED, @LastID)
Posted in SQL Server, Tips'n'Tricks
No Comments »
Apr 19th, 2009 by ocvirek.com
There’s a simple and effective way to precompile your ASP.NET application in desired folder prior to publishing it (e.g. uploading to web server via FTP):
C:\Windows\Microsoft.Net\Framework\v2.0.50727\aspnet_compiler.exe -v /WEBSITENAME -p “C:\Projects\WebSiteSource” “C:\Projects\WebSitePublished”
And, as you probably already know, adding any other uncompiled files to this precompiled version (e.g. uncompiled user controls .ascx meant to be loaded dynamically via LoadControl), you have to change attribute updatable to true in PrecompiledApp.config file:
<precompiledApp version=”2″ updatable=”true”/>.
Hope this helps. Cheers.
Posted in ASP.NET, Visual Studio, Tips'n'Tricks
No Comments »
Dec 21st, 2008 by ocvirek.com
I’ve just come to conclusion that there’s another annoying thing which is actually very common when working with TableAdapters, ObjectDataSource and DataBinded controls on a WebForm. For example, when you use a DataBinded DropDownList control in a DetailView control to choose one value for your ForeignKey, everything works fine, until your ForeignKey has a Null value, and there is no such value in a DropDownList. You will immidiately get this error from the title. Off course, one ObjectDataSource is used to provide DataBinding for a DetailView control, and another is used to populate your DropDownList. Regarding this other one, the best thing you can do is to create a view, stored procedure or a SELECT statement which will include a NULL value, for example:
SELECT EmployeeTypeID, EmployeeTypeDesc FROM EmpyloeeType
UNION SELECT NULL, ‘– None selected –’
and then populate DropDownList with it. But you will still get this error if your TableAdapter, which will be used for populating it, has a PrimaryKey constratint on a EmployeeTypeID field (in this example). In order to solve this, we will have to Delete this Primary Key by right clicking on the row in a TableAdapter in a DataSet designer, and then choosing Delete Key option. But still, after saving changes you will still get this error. Well I guess this is a Visual Studio’s bug rather then a feature. TableAdapter methods/queries are pretty tricky if you mess with them so make sure that always recreate them insted of trying to change them through properties. In order to do so, right click on them, choose Configure and them complete all wizard steps. In worst cases, if this doesn’t help at all, delete whole TableAdapter and then recreate new one, but this time take more care. I’ve posted this since I’ve found more complicated workarounds presented on the web, and the fact is, this is quite simple once you understood it correctly.
Posted in SQL Server, ASP.NET, Visual Studio
No Comments »
Dec 20th, 2008 by ocvirek.com
I just discovered that hibernation option wasn’t available any more on my Vista Business laptop. I discovered simple and effective way to turn it back on. Just open command prompt and type: powercfg /hibernate on. Then restart your PC. After that, hibernation should be available again.
Posted in Windows Vista
No Comments »
Nov 11th, 2008 by ocvirek.com
If you are running out of disk space on your system partition (disk C) with Windows Vista, there is a way to free up large amounts of disk space with Disk Cleanup utility. First of all, you should get rid of all temporary files such as Temporary Internet files, Recycle Bin and files in Temp folder. But most disk space is occupied with shadow storage which keeps all of you restore points. To investigate how much space is allocated by shadow storage, open up command prompt and type:
vssadmin list shadowstorage
You will get output like this:
vssadmin 1.1 - Volume Shadow Copy Service administrative command-line tool
(C) Copyright 2001-2005 Microsoft Corp.
Shadow Copy Storage association
For volume: (C:)\\?\Volume{xxxx-xxxx-xxxx-xxxx}\
Shadow Copy Storage volume: (C:)\\?\Volume{xxxx-xxxx-xxxx}\
Used Shadow Copy Storage space: 951.301 MB
Allocated Shadow Copy Storage space: 1.172 GB
Maximum Shadow Copy Storage space: 4.394 GB
Allocated Shadow Copy Storage is actual disk space that is occupied with shadow storage. If you don’t need all restore points and are quite satisfied with most recent one, you can delete all previous points and free up most of the disk space. In order to do so, click Clean up button and then click OK. Then check again how much free disk space is there on your system partition, you should notice a great change :). Please make sure that you know what you are doing since deleted restore point can not be restored once you cleaned them up.
Posted in Windows Vista
No Comments »
Nov 4th, 2008 by ocvirek.com
When creating a copy of fully installed Virtual PC image with Windows XP Professional, there is a couple of tasks that has to be done in order to be able to run both VPC-s in the same workgroup or domain. These tasks are:
1. Genereting a new Security ID for a VPC (New SID) on a running VPC
In order to generate new SID, download NewSID program onto your VPC from this address: http://technet.microsoft.com/en-us/sysinternals/bb897418.aspx. Make sure to read instructions carefully. Stop IIS before using this program with the following command line: net stop iisadmin /y. Use this program to get a new SID for VPC. Please note that VPC will be rebooted during this process.
2. Renewing a MAC address (so that DHCP can give you VPC new IP address)
To get a new MAC address, shut down your VPC, then backup your .VMC configuration file. Edit .VMC file with the Notepad and remove MAC address (xxxxxxxxxx) from the following line:
<ethernet_card_address type=”bytes”>xxxxxxxxxxxx</ethernet_card_address>.
After removing the nubmer the line should look like this
<ethernet_card_address type=”bytes”></ethernet_card_address>.
After you remove the number, save the .VMC file.
3. Restarting VPC
Now reboot your VPC. Virtual PC will create a new MAC address the next time you start the virtual machine. DHCP should dedicate a new IP address to your VPC. Check it by typing following command line: ipconfig /all and check Physicall Address (MAC address) and IP address.
Disclaimer: I don’t take any responsibility for possible damange or loss of data. You do it on your own risk. Make sure to have latest versions of Virtual PC and NewSID programs.
More reading:
http://www.aspdeveloper.net/Virtual_PC/rn-739-36343_How_to_generate_new_MAC_address.aspx
http://blogs.msdn.com/virtual_pc_guy/archive/2005/02/15/373366.aspx
Posted in Virtual PC, Tips'n'Tricks
No Comments »
Nov 3rd, 2008 by ocvirek.com
If for some reason enabling CLR in SQL Server 2005 does not work from within SQL Server Surface Area Configuration GUI, there is a way to enable it through good old T-SQL. Just open SQL Server Managment Studio and type in:
sp_configure ‘CLR enabled’,1
GO
reconfigure
GO
Posted in SQL Server, Visual Studio, Tips'n'Tricks
No Comments »
Jun 20th, 2008 by ocvirek.com
If you get blank screen when you click Network and you have “red X” on you network icon in system tray and you just can’t establish any network connection then probably some of the following services isn’t started well:
Function Discovery Provider Host
Function Discovery Resource Publication
Network Connections
Network List Service
Network Location Awareness
Network Store Interface Service
Usually Network List Service is not started because of missing security account:
- Right click ‘Computer’
- Click ‘Manage’
- Under the ‘System Tools’ section, double click ‘Local Users And Groups’
- Click ‘Groups’
- Right click ‘Administrators’
- Click ‘Add to group’
- Click ‘Add’
- Click ‘Advanced’
- Click ‘Find Now’
- Double click ‘Local Service’
- Click ‘Ok’
‘NT AuthorityLocal Service’ should show up in the list now
- Click ‘Ok’
- Close computer management and reboot
To find more about this problems check out this: http://forums.techguy.org/windows-vista/688972-solved-networking-gone-crazy-vista.html and http://8help.osu.edu/3618.html
Posted in Networking, Windows Vista
No Comments »
Jun 12th, 2008 by ocvirek.com
You’ve got your ASP.NET application working just fine and you have nothing changed but “all of a sudden” you get this exception on your data binded form: “Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints“. Off course, you’re sure that’s everything fine with your database. So what to do? First you should check out your DataSets and TableAdapters. Probably this error is caused by MaxLength property of one of fields in problematic TableAdapter. It happens if your field isn’t big enought for the data provided by user. For example, if string fields MaxLegnth property is set to 50 and then user enters 60 characters, I’m pretty convinced that you’ll get this error. So, solution is to make MaxLenght big enough to accept user input. I hope this helps.
Posted in ASP.NET, Visual Studio
1 Comment »
May 22nd, 2008 by ocvirek.com
Depending how lucky you were after installing Vista SP1 there was a great deal of chance that you’ve stumbled on the problem where you weren’t able to create and establish VPN connection on your Windows Vista. Well, I had this problem for quite some time and after fair amount of internet research I still wasn’t able to find apropriate solution to fix this. Symptoms were typical - I just couldn’t create and save VPN connection for later. I always get this error: “The Wizard cannot connect”. I don’t use any 3rd Party VPN software or firewalls, so I’ve tried with uninstalling AntiVirus Software (AVG 8.0 Free), disabling Windows Firewall etc. Some guys even reinstalled Service Pack 1 which actually helped. But solution is far more simpler. You just have to make sure that Telephony Serivce and Terminal Services are stared. Now, start your VPN wizard again, create a new VPN connection and establish it. Now everything should work just fine.
Posted in Windows Vista, Tips'n'Tricks
No Comments »