"<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>" + docname + "</Value></Eq></Where>"
But I get this error One or more field types are not installed properly. Go to the list settings page to delete these fields.
"<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>" + docname + "</Value></Eq></Where>"
- U2U CAML Query Builder which gives you an UI for building the query.
I posted this as a comment but perhaps it is a part of the answer: You need to use the field internal name in your query, not the display name.
The easiest ways to find internal name of columns: 1. If you see the field in list settings, click it. the internal name will be in the query string of the settings page. 2. if you see the field in the list view, sort or filter by it. Again the internal name will be in the query string.
If these fail, in SP2013 you can use the REST API: http://[your site]/_api/web/lists/getByTitle('[list name]')/Fields?$select=Title,InternalName This will get you a list of all fields in that list with their title and internal name.
How to query data for CQWP?
Why doesn't CAML Query Get Data from a Column Name?