How to read DBF to Datatable

OleDbConnection oConn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Temp;Extended Properties=dBase III");
OleDbCommand command = new OleDbCommand("SELECT * FROM Test.DBF", oConn);
DataTable dt = new DataTable();

How to Backup MYSQL Databases

REM Export all databases names to file
mysql -h your-server-ip -u user-name -ppassword information_schema --skip-column-names --execute="SHOW DATABASES;" > databases.tmp
echo "Start!"
REM Look over database names

REM Outter loop to get table names

for /F %%A in (databases.tmp) do (
   echo "Exporting table Names for %%A"
   mysql -h your-server-ip -u user-name -ppassword %%A --skip-column-names --execute="SHOW TABLES;" >"%%A_tables.tmp"

   mkdir %%A

#### nested loop to create table name files per table
   for /F %%B in (%%A_tables.tmp) do (
   echo "Exporting data for %%B of %%A"
   mysqldump -h your-server-ip -u user-name -ppassword %%A %%B> "%%A\%%A_%%B.sql"

del *.tmp


Only Office – Multifunctional service for business with low cost

Only Office is a great tool which can use by any small scale organization for Project management, online editors, documents management, emails and few more things. Like all the features are available in other products too like Google, Microsoft Office Online, Microsoft SharePoint. All these products stores data to their own cloud servers, they are some expensive for the start-ups or small companies, also their model based on subscription. We need to pay them monthly or yearly subscription.

Only office also host on their cloud machines but we can setup this on our machines too. ?A subscription model of this application also cost effective. Any small scale company can afford it. If they want to setup their own machine then it can also be possible.

If we have a small team and would like to share docs between them without worrying about versions, sharing permissions, we can do it easily with this tool. It also support web editors where anyone can open and edit documents without installing the required software?s on local machines. This will help to reduce resources as well.

Only office also easily integrated with existing applications using iframe without worrying and wasting lot of time. It has application programming interface (API) too, so programmers can easily integrate it. Programmers can easily create real time users, upload files, sharing permission to the file without going to portal.

Only office installation is also easy, it provides single click installation for beginners, setup will take case all the things, we need to provide public IP and credentials to start that.

Only office comes with two applications, first Community Server and second one is document server. Community server will take care of all the things like project management, users, sharing, emails, authentication and authorizations. Document server serve the documents online with the support of Iframe.

If anyone wants to use the application for editors only then he can setup document server ONLY. Both application needs to install on separate machines. They are internally responsible for data transfer.

See more about only office please click here?

How to export schema of MYSQL Database?

If you need schema of your MYSQL database for backup or any copy database to another server, then you must need schema with or without data.

GUI tools like SQLYog, WebYog or PHPmyAdmin will best example for that. But if you need any command or utility then MYSQLDUMP has most important role.

For using mysqldump you can export schema as well as data with it.

mysqldump -u root -p –no-data [mydatabase] > myschema.sql

Basic Authentication in ASP.Net MVC Web API

ASP.NET Web API is a great tool to create lightweight, HTTP services that reach a broad range of clients, including all browsers and mobile platforms.

In most of scenarios we need authentication to restrict services . There are two ways to restrict it

– Forms authentication
– Windows authentication

Forms authentication is a mechanism that works well in interactive web applications, but Windows authentication is not widely used. Now days services are invoked from the browser using jquery or javascripts for mobile platforms because application are widely used on mobile devices.

HTTP authentication is part of the standard protocol and can be easily handled by client and mobile platforms. To implement Basic authentication in ASP.NET Web API by extending AuthorizeAttribute. But its sometimes not working well, Another a custom message handler by deriving from DelegateHandler class.

Below is the code sample which is deriving from DelegateHandler class and working well.

Code Block:

public class BasicAuthMessageHandler : DelegatingHandler
private const string BasicAuthResponseHeader = "WWW-Authenticate";
private const string BasicAuthResponseHeaderValue = "Basic";

public IProvidePrincipal PrincipalProvider = new DummyPrincipalProvider();

public BasicAuthMessageHandler(HttpConfiguration httpConfiguration)
InnerHandler = new HttpControllerDispatcher(httpConfiguration);

protected override System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
AuthenticationHeaderValue authValue = request.Headers.Authorization;
if (authValue != null && !String.IsNullOrWhiteSpace(authValue.Parameter))
Credentials parsedCredentials = ParseAuthorizationHeader(authValue.Parameter);
if (parsedCredentials != null)
IPrincipal myPrincipal = PrincipalProvider.CreatePrincipal(parsedCredentials.Username, parsedCredentials.Password);
Thread.CurrentPrincipal = myPrincipal;
HttpContext.Current.User = myPrincipal;
return base.SendAsync(request, cancellationToken)
.ContinueWith(task =>
var response = task.Result;
if (response.StatusCode == HttpStatusCode.Unauthorized
&& !response.Headers.Contains(BasicAuthResponseHeader))
, BasicAuthResponseHeaderValue);

if (response.StatusCode == HttpStatusCode.Unauthorized)
var content = new StringContent("Invalid Credentials");
response.Content = content;
response.StatusCode = System.Net.HttpStatusCode.Unauthorized;
return response;

private Credentials ParseAuthorizationHeader(string authHeader)
string[] credentials = Encoding.ASCII.GetString(Convert
new[] { ':' });
if (credentials.Length != 2 || string.IsNullOrEmpty(credentials[0])
|| string.IsNullOrEmpty(credentials[1])) return null;
return new Credentials()
Username = credentials[0],
Password = credentials[1],

public interface IProvidePrincipal
IPrincipal CreatePrincipal(string username, string password);

public class Credentials
public string Username { get; set; }
public string Password { get; set; }

public class DummyPrincipalProvider : IProvidePrincipal
public IPrincipal CreatePrincipal(string username, string password)
//check user using any membership provider Websecurity/Membership
if (!WebSecurity.Login(username, password, persistCookie: false))
return null;
var identity = new GenericIdentity(username);
IPrincipal principal = new GenericPrincipal(identity, Roles.GetRolesForUser(username));
return principal;


name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional },
constraints: null,
handler: new BasicAuthMessageHandler(GlobalConfiguration.Configuration)


public class ValuesController : ApiController
// GET api/values
public IEnumerable<string> Get()
return new string[] { "first", "second" };


using (HttpClient client = new HttpClient())
client.BaseAddress = new Uri("");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Authorization", Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format("{0}:{1}", userName, password))));
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var Response =await client.GetAsync("api/accounts/validateuser");



How to cast MSSQL Datetime in MYSQL

If any one mograte MSSQl data to MYSQl then there will be issue related to datetime column. SQL management studio generate script export the datetime value to hex value and MYSQL doesn’t recognized it.

To solve this issue just create a function and called it where required.

create function sp_ConvertSQLServerDate(dttm binary(16))
returns datetime
return CAST(
‘1900-01-01 00:00:00’ +
INTERVAL CAST(CONV(substr(HEX(dttm),1,8), 16, 10) AS SIGNED) DAY +
INTERVAL CAST(CONV(substr(HEX(dttm),9,8), 16, 10) AS SIGNED)* 10000/3 MICROSECOND

and how to use it in MYSQL:

SELECT sp_ConvertSQLServerDate(0x00009E3000C98FF6) AS BinaryData