Thursday, June 11, 2009

Restoring a .bak file to a SQL Server database

source: http://blog.sharepointdevelopment.nl/post/Restoring-a-bak-file-to-a-SQL-Server-database.aspx
Author:Nick Boumans

Sometimes you have to restore a .bak file to a SQL Server database where the .bak file was not originally back-upped from. You can do this either by a script or using SQL Server Management studio. By using Management Studio, you have to follow the next steps:

- Open SQL Server Management Studio (either Enterprise or Express)
- Right Click Databases -> Restore Database…
- Select your To Database e.g. OrdersNew
- Select from device and select your .bak file
- Move to the item options (you're standard in General)
- Check or the database paths are correct, otherwise correct them
- Go back to the general tab
- Check your database and hit the OK button

Vaibhav

Wednesday, May 6, 2009

Citrix Receiver for iPhone and Doc Finder

Citrix is a nice company and they work really well towards innovative stuff.

Finally Doc Finder is out. We worked pretty hard for around 6 months for the release of version 1.0 of this project. Both my site director and my test lead were superb in their approach towards the development of this project and I must say without both of them this thing wouldn't have been possible. VPRD team was very nice and innovative as well. They came up with amazing designs for the UI and they also knew what a user expects for the best experience. I really loved working on this project and I must say all the people involved in this project came up with some awesome ideas.

I found this demo video on you tube, it's a must watch at least for all citrites and iPhone/ XenApp users.. This is video for 0.9 version of Doc Finder project and v1.0 has some more cool features like search, recent documents, stylish help screen and an animated settings page:o)



My favorite part of this video are the last 2 minutes of the demo coz that's the part in which we get to see Doc Finder.

It was fun working on it as a developer :o)

All the best Citrix...

Cherio!!!
vaibhav

Thursday, April 16, 2009

Could not find any resources appropriate for the specified culture or the neutral culture.

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "XXXYYY.en-US.resources" was correctly embedded or linked into assembly "AAABBB" at compile time, or that all the satellite assemblies required are loadable and fully signed.

I wasted a lot of time to find out the reason behind this error. This was coming up when I was trying to use culture specific satellite DLL.

After search the complete web I found the following answer:

It is not because the resource manager didn't find the satellite assembly but because the embedded .resources file in the satellite assembly doesn't have a full
name. In this case, the full name is "MyLib.Resources.es-MX.resources", but
the .resources file's name is "Resources.es-MX.resources".

When you use the resgen tool to convert .resx file to common language runtime binary .resources file, you should add the namespace name of your project in the front of the converted .resources file. The following is a sample.

resgen Resources.es-MX.resx MyLib.Resources.es-MX.resources

Thus, the .resources file has a full name. Then you use AL.exe tool to bundle the .resource file into a satellite assembly and place this satellite assembly to the es-MX subdirectory of the application's bin/debug folder.

Run the application again and you should see the correct result.


Thanks to Linda Liu [MSFT] for the answer...
source : http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework/topic55934.aspx


vaibhav Chugh

Wednesday, April 8, 2009

Remove flicker in listbox C#

I read over 100 articles on the web just one was able to help me and that too was ignored by others in the discussion.

Well, if you are adding less number of items to a listbox then
listbox1.beginupdate()
listbox1.add(item);
listbox1.endupdate();

should work for you just fine. There shall be no flicker.
using doublebuffered user control / form may also solve the problem. In some cases

this.SetStyle(ControlStyles.UserPaint  ControlStyles.OptimizedDoubleBuffer 
ControlStyles.AllPaintingInWmPaint ControlStyles.SupportsTransparentBackColor,
true);
may also work.

but in my case the data was coming at a very high speed and high quantity and I had to display this large amount of data in an owner drawn list box.

this.SuspendLayout();
foreach (DataItem ditem in ditems)
{
listbox1.Items.Add(ditem);
}
this.ResumeLayout();


the above code helped me in getting a pretty smooth layout.

hope it helps
Vaibhav Chugh

Thursday, March 5, 2009

CopyRight symbol in C#

This was funny to find....

2 good ways to do it

string copyright="\u00A9";

string completetext=copyright + "myCredits";

Much better way =>
press Alt and then 0 1 6 9..this will convert into the copyright symbol

n u r good to go :)

vaibhav

Wednesday, February 18, 2009

How to release IntPtr handle C#

If you are using IntPtr as handles in C# code and wish to avoid handle leaks you may use :

IntPtr handle = some handle;
Marshal.Release(handle);

Google search didn't give me correct answer instantly so I added it here :)

cherio!!
Vaibhav


Saturday, February 7, 2009

height and width of text with specific font

When you draw a string on a C# form if you want to figure out how many pixel wide and high the text will be use:

TextRenderer Class

To measure the size you may use

TextRenderer.MeasureText :

TextRenderer.MeasureText (String, Font, Size)
TextRenderer.MeasureText (IDeviceContext, String, Font, Size)
TextRenderer.MeasureText (String, Font, Size, TextFormatFlags)
TextRenderer.MeasureText (IDeviceContext, String, Font, Size, TextFormatFlags)

It returns back System.Drawing.Size which has height and width of the text you wanted.


To draw text you may use:
private void RenderText1(PaintEventArgs e)
{
TextRenderer.DrawText(e.Graphics, "Regular Text", this.Font,
new Point(10, 10), SystemColors.ControlText);
}


for more details you may visit:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textrenderer(VS.80).aspx

Wednesday, February 4, 2009

Disable right click pop up on textbox in C# winform

It took me almost 3 hours to google the correct way to fix this one...

There are 2 ways of disabling right click on textbox in a C# winform.

1. create a new context menu and add it to the text box control :

TextBox textbox1 = new TextBox();
ContextMenu cm = new ContextMenu();
textbox1.controls.add(cm);

and you are done.

2. Just do
textbox1.ShortcutsEnabled = false;

second one is short and sweet....

Wednesday, January 7, 2009

Adding icon to C# application

To add an icon to the exe given out by your C# code. Do the following:

In visual studio. Select

  1. Project
  2. [Project Name] Properties
  3. Application
  4. Icon
  5. (From the Combobox select)
and apply the .ico file :)

you are all set :)

vaibhav