I had this error on my HP Photosmart and after much fruitless searching for the answer, reinstalling drivers and tweaking settings, discovered that as of 1 September 2016, for older models, web services are no longer supported. See the following link to verify [retrieved 15/10/2019]:
https://support.hp.com/gb-en/product/hp-photosmart-wireless-e-all-in-one-printer-series-b110/4022328/model/4022329/document/c05211712/
Tuesday, 15 October 2019
Thursday, 7 March 2019
MySQL Can't create/write to file (Errcode: 13)
I wanted to export a table from MySQL to CSV format, so I wrote the following MySQL to a file:
use mydb;
select *
from mytab
into outfile '/folder/myfile.csv'
fields terminated by ','
enclosed by '"'
lines terminated by '\n';
I then ran the following command line:
sudo mysql -u root < myExport.sql
This generated the following error:
ERROR 1 (HY000): Can't create/write to file '/folder/myfile.csv' (Errcode: 13)
After searching for answers to no avail, I then changed the MySQL code as follows:
select *
from mytab
into outfile 'myfile.csv'
fields terminated by ','
enclosed by '"'
lines terminated by '\n';
use mydb;
select *
from mytab
into outfile '/folder/myfile.csv'
fields terminated by ','
enclosed by '"'
lines terminated by '\n';
I then ran the following command line:
sudo mysql -u root < myExport.sql
This generated the following error:
ERROR 1 (HY000): Can't create/write to file '/folder/myfile.csv' (Errcode: 13)
After searching for answers to no avail, I then changed the MySQL code as follows:
select *
from mytab
into outfile 'myfile.csv'
fields terminated by ','
enclosed by '"'
lines terminated by '\n';
I then re-ran the above command line command and used the following Linux command to search the entire file system for the file:
find -name myfile.csv
It found the file in /var/lib/mysql/mydb.
Monday, 30 April 2018
How to Create a Fake HttpContext to Unit Test MVC Controller
Given: I needed to unit test that a response status code had been set within a controller action.
When: I didn't particularly want to refactor due to this being existing code.
Then: After experimenting unsuccessfully with creating various HttpContext classes, I found the simplest solution to be as follows within my test method:
var request = new HttpRequest("", "http://tempuri.org/", "");
var response = new HttpResponse(TextWriter.Null);
var httpContext = new HttpContextWrapper(new HttpContext(request, response));
_myController.ControllerContext = new ControllerContext(httpContext, new RouteData(), _myController);
var result = _myController.SomeAction(...some parameters...);
Assert.AreEqual(400, response.StatusCode);
When: I didn't particularly want to refactor due to this being existing code.
Then: After experimenting unsuccessfully with creating various HttpContext classes, I found the simplest solution to be as follows within my test method:
var request = new HttpRequest("", "http://tempuri.org/", "");
var response = new HttpResponse(TextWriter.Null);
var httpContext = new HttpContextWrapper(new HttpContext(request, response));
_myController.ControllerContext = new ControllerContext(httpContext, new RouteData(), _myController);
var result = _myController.SomeAction(...some parameters...);
Assert.AreEqual(400, response.StatusCode);
Wednesday, 24 May 2017
SQL Shortcut Comparative "And" and "Or" Operator Conditions
In SQL Server Management Studio (SSMS), the following code returns "OK", suggesting that the evaluation conditions in SQL are shortcutted (ie. as soon as a condition is met, the code doesn't evaluate any subsequent conditions):
select case when 1=2 or 2=2 or 1/0 = 2 then 'ok' else 'no' end
Had all conditions been evaluated, a "divide by zero" error would have occurred.
I've not looked into whether this is standard ANSI SQL behaviour, but thought I'd share in case it is of use or interest to others.
I've not looked into whether this is standard ANSI SQL behaviour, but thought I'd share in case it is of use or interest to others.
Thursday, 19 February 2015
Permission denied when pushing to GitHub remote repository
When I tried to push code to GitHub recently, I got the following error despite running PuTTY and loading the SSH key that was associated with my GitHub account:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
It turned out that one of my settings in Git Extensions had reverted. I went into Settings, Settings, Ssh and selected the option against PuTTY. I was then able to push successfully.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
It turned out that one of my settings in Git Extensions had reverted. I went into Settings, Settings, Ssh and selected the option against PuTTY. I was then able to push successfully.
Labels:
Git,
GitHub,
Troubleshooting
Tuesday, 3 February 2015
List All Stored Procedures Within a SQL Database and Then Grant Execute on Them
It's been too long since I last blogged.
Thought I'd dust things off with this little snippet of T-SQL to list all stored procedures that exist within a specified SQL database:
USE YourDatabaseNameHere
GO
SELECT NAME
FROM SYSOBJECTS
WHERE TYPE = 'P'
AND LEFT(NAME,2) <> 'sp'
AND LEFT(NAME,2) <> 'dt'
This can be useful if you wish to grant execute permissions on these objects to your database login. For example, the following T-SQL will literally write out the commands you need to run in order to grant such execute permissions:
SELECT 'GRANT EXECUTE ON ' + NAME + ' TO YourDatabaseLoginNameHere'
FROM SYSOBJECTS
WHERE TYPE = 'P'
AND LEFT(NAME,2) <> 'sp'
AND LEFT(NAME,2) <> 'dt'
You can take the output from the above, paste into a query window and run:
GRANT EXECUTE ON MyStoredProc TO YourDatabaseLoginNameHere
Thought I'd dust things off with this little snippet of T-SQL to list all stored procedures that exist within a specified SQL database:
USE YourDatabaseNameHere
GO
SELECT NAME
FROM SYSOBJECTS
WHERE TYPE = 'P'
AND LEFT(NAME,2) <> 'sp'
AND LEFT(NAME,2) <> 'dt'
This can be useful if you wish to grant execute permissions on these objects to your database login. For example, the following T-SQL will literally write out the commands you need to run in order to grant such execute permissions:
SELECT 'GRANT EXECUTE ON ' + NAME + ' TO YourDatabaseLoginNameHere'
FROM SYSOBJECTS
WHERE TYPE = 'P'
AND LEFT(NAME,2) <> 'sp'
AND LEFT(NAME,2) <> 'dt'
You can take the output from the above, paste into a query window and run:
GRANT EXECUTE ON MyStoredProc TO YourDatabaseLoginNameHere
GRANT EXECUTE ON AnotherStoredProc TO YourDatabaseLoginNameHere
GRANT EXECUTE ON AndAnotherStoredProc TO YourDatabaseLoginNameHere
Friday, 19 July 2013
RESTORE cannot process database 'X' because it is in use by this session
When running a restore database query, I got the above error in SQL Management Studio. This was due to having the database 'X' selected in the dropdown list of databases, as suggested by the second part of the error message, which stated "It is recommended that the master database be used when performing this operation."
I changed the dropdown to another database 'Y' and was able to re-run the query without error.
I changed the dropdown to another database 'Y' and was able to re-run the query without error.
Labels:
SQL,
Troubleshooting
Subscribe to:
Posts (Atom)