Posts

Showing posts with the label SQL

How to create a security ASP.NET Web API controller

 Hi, Here is a code that has base response class and use it in an ASP.NET Web API controller to send a response with a cookie and security headers. This code creates a BaseResponse<T> class with a Status property and a Data property of type T. In the Post method of MyController, a new HttpResponseMessage is created with a status of OK and the content set to a serialized BaseResponse<string>. A cookie is added to the response headers, and then several security headers are added. The X-Content-Type-Options header is set to nosniff to prevent the browser from trying to interpret content with a MIME type that doesn't match the declared type. The X-Frame-Options header is set to SAMEORIGIN to prevent the page from being displayed in a frame or iframe. The Content-Security-Policy header is set to only allow content from the same origin In this code, I've assumed that you have a service IDatabaseService with a method CheckIfExists that checks if an ID exists in the databa...

The URL is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web at SharePoint

Image
I recently had the following error when I tried to add a document to a document library. The URL <file name>  is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.  A quick search on google said that brought the resources of SQL Server. I checked and indeed I increased the resources but to no avail. Even my examination chrome and Internet Explorer. I checked Word file, PDF, and even a small text file. A.  Nothing helped. I opened a new document library, and in fact it could add document :)  Ok ... what is the problem ???  It should be noted in the document library came from List Definition and Content Type preset. I started to check each field and field Then I got a Date Field in the file probably was not his elemet.xml incubated right.  When I set it to Today date .... it worked  All it needed was simply to write the true definition of the field  ...

Free Disk Space on SQL Server

Image
We often are needed to develop command and control systems. What happens if we need to develop a system that tell us about disk space SQL server Here is the code Select @@servername as 'SQL Server Name' , getdate() as Date     EXEC master..xp_fixeddrives Yours, Roi 

Invalid column name - sql server

Image
This case that happened to me when creating SQL table column I created a SQL table column . Then I received the following message on StoredProcedure or even in Select. Invalid column name Invalid column name Invalid column name What can be problem 2 tables or one table with both columns use Stored procedures to decouple scope I wrote this query to see if there is a problem with my columns select    name  from  sys.columns  where  object_id = object_id( 'Your_Table' ) I didn't see any problem with my columns OK.... What to do Go to the table where they are added to the column, check whether it has a trigger (for each table by columns also have triggers), and if there is a table trigger, stopped him, and suddenly everything starts to work. If you open the trigger you will understand that change is copying the data to another table that there has to add the column and so on. Press CTRL+SHIFT+R   on table !!! ...

Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.

Image
How to insert/update image column om SQL? When you try to do this on sql server 2008 you got an error update [tbl_items] set [ImagePlayer]= 'C:\Projects\Images\item.jpg' where [ID]=1 The error message was: Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query. Implicit conversion from data type varchar to varbinary(max) is not allowed. Use the CONVERT function to run this query All you need is to do BulkColumn Code for update update [tbl_items] set [ImagePlayer]=BulkColumn FROM OPENROWSET ( Bulk 'C:\Projects\Images\item.jpg' , SINGLE_BLOB) AS BLOB where [ID]=1 (1 row(s) affected) Code for Insert INSERT INTO [ScoutMe].[dbo].[tbl_Players]   ([ID],   [ImagePlayer])    SELECT 1,      BulkColumn FROM OPENROWSET (        Bulk 'C:\Projects\Images\item.jpg' , SINGLE_BLOB) AS BLOB...

Saving changes is not permitted - Sql server

Image
I got an error message when I try to change my table on sql server 2008 R2 Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created. Saving changes is not permitted   All you need to is go to: Options -> Designers -> Table and Database Designers ... and turn off the " Prevent saving changes that requirde table re-creation " Prevent saving changes that requirde table re-creation and click OK Twice User Chenges Thanks, Roi

How to get updates of changes to the database

Image
Have you ever encountered in developing longer and you do not remember what you did and what updated and created. No - then you can not continue reading the article. If so - and also worked with a database ... So probably you wanted to know what you did (and don't remember) Here's a query that returns all the tables,views,stored procedures and functions which have changed in the last 30 days (you can change 30 to any number) set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go -- ============================================= -- Author:         Roi Kolbinger -- Create date:   02/08/2008 -- Description:    Get tables,views,stored procedures and functions that modified for 30 days -- ============================================= ALTER PROCEDURE [dbo] . [GetAllDBDetails] AS BEGIN -- ======================views======================= SELECT name AS view_name   , SCHEMA_NAME ( schema_id ) ...