CodeWrapper.com RSS - Questions And Answers http://www.CodeWrapper/Questions Presenting 20 latest Code Questions. en-US CodeWrapper.com RSS Feed How do I change user owner in SQL Server table? http://www.CodeWrapper.com/Questions/View/30/how-do-i-change-user-owner-in-sql-server-table 129283768131422671 mordec Hi, I would like to know how to change the user owner on a table in SQL server.
Answer # 1 by mordec: I found the answer. EXEC sp_changeobjectowner tblName, newuser Additional info
Change SQL server host name using SQL script. http://www.CodeWrapper.com/Questions/View/29/change-sql-server-host-name-using-sql-script 129283768131588676 marko In case the SQL server machine's name was changed. How do I change the host name in SQL server?
Answer # 1 by Davido: You can read all about it here.
How to determine if the windows HTTP service is running? http://www.CodeWrapper.com/Questions/View/28/how-to-determine-if-the-windows-http-service-is-running 129283768131715621 JimiR The HTTP is not showed in the Windows Service Controller. How is it possible to get the state of the HTTP service?
Answer # 1 by Davido: You can use sc command. On the cmd, enter the following command: sc query HTTP If you are using .NET you can use: ServiceController httpService = new ServiceController(andquot;HTTPandquot;); if (httpService.Status == ServiceControllerStatus.Running) { // do something... }
Setting Combobox as read only in C# WinForms. http://www.CodeWrapper.com/Questions/View/27/setting-combobox-as-read-only-in-c-sharp-winforms 129283768132281991 Phosty How do I set combobox as read only which users can not modify?
Answer # 1 by Davido: You can set the Combobox properties or by changing it by code: myCombobox.DropDownStyle = ComboBoxStyle.DropDownList;
How do I convert Big Endian to Small Endian using C#? http://www.CodeWrapper.com/Questions/View/26/how-do-i-convert-big-endian-to-small-endian-using-c-sharp 129283768132408936 David G. Hi, Is there a C# API to convert big endian to small endian and vice versa?
Answer # 1 by Unknown(Google): You can use BitConverter to get the bytes from the int/long, use the Array to reverse the order of the bytes and then convert bytes back to int/long. arrayValue = BitConverter.GetBytes(lValue); Array.Reverse(arrayValue); return BitConverter.ToInt64(arrayValue, 0);
SQL Server - using a variable as table name in FROM clause. http://www.CodeWrapper.com/Questions/View/25/sql-server-using-a-variable-as-table-name-in-from-clause 129283768132535881 Unknown(Google) I want to make SQL select query where the FROM is variable. DECLARE @tableName SET @tableName = "MyTable" SELECT * FROM @tableName I am getting the following error: Must declare the table variable @tableName I would like to know if the only way to solve this error is by using Dynamic SQL. DECLARE @sql = 'SELECT * FROM ' + @tableName EXEC(@sql) How to get oldest files in a directory in C# http://www.CodeWrapper.com/Questions/View/24/how-to-get-oldest-files-in-a-directory-in-c-sharp 129283768132614001 Billm I would like to find the oldest files in a given directory using c#. What is the simplest way to do that?
Answer # 1 by marko: It is possible to get the oldest files using DirectoryInfo and Array.Sort. DirectoryInfo directorInfo = new DirectoryInfo("my_folder"); FileInfo[] files = directorInfo.GetFiles(); Array.Sort(files, delegate(FileInfo file1, FileInfo file2) { return file1.CreationTime.CompareTo(file2.CreationTime); }); If you would like to change the order (newest to oldest) - just swap file1, file2.