Posts

Showing posts from November, 2009

Oledb and SQL Clients

While dealing with database stuff in .Net, we might worked with Oledb and SQL Clients. Here are, some of the methods which help us to get the database tables, views, primary keys...etc OLEDB Client/ SQL Client Namespace System.Data.OleDb/ System.Data.SqlClient ConnectionString Provider=SQLOLEDB.1;Persist Security Info=False;User ID={user};Password={password};Initial Catalog={Database};Data Source={host name/IP}; Server={host name/IP}; Database={dbname}; User ID={user}; Password={sqlServerPassword}; For various connection strings, have a look at connectionstrings Getting Table list from database DataTable dtObj = {connection}.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object() {null, null, null, "Table"}); DataTable dtObj = {connection}.GetSchema("Tables"); Getting Views List DataTable dtObj = {connection}.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object() {null, null, null, "View"}); DataTable dtObj = {connection}.GetSchema(&q