Knowledge Base Category: Development

Add an access database as a LinkedServer in Microsoft SQL 2008 R2

USE [master]
 GO

EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'AllowInProcess' , 1
 GO

EXEC master . dbo. sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0' , N'DynamicParameters' , 1
 GO

 EXEC sp_addlinkedserver 
   @server = N'LinkedServer', 
   @provider = N'Microsoft.ACE.OLEDB.12.0', 
   @srvproduct = N'OLE DB Provider... 						
						
Read more

Access connections from Visual Studio

Import classes
using System.Data;
using System.Configuration;
using System.Data.OleDb;
set up your app config
<add name="AccessConnection" 
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\location\accessdb.mdb;
		Persist Security Info=False;;"/>
  public DataTable accessquery()
       ... 						
						
Read more

Connection String

Quick Connection String for SQL Database for webconfig:
 <add name="ANYNAME" connectionString="Data Source=SERVERNAME;
Initial Catalog=DBNAME;User Id=USERNAME;Password=PASSWORD;" providerName="System.Data.SqlClient" />
...
Read more

Regex Validator

Helpful code for verification:
  public bool isphonevalid(string phone)
        {
            string isphone = @"^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$";
            //return Regex.IsMatch(phone,... 						
						
Read more