Posts

Showing posts with the label Database

Distinct count in MS SQL

The below code will retrieve distinct count from a table in SQL select ename, count(ename) from emp Group by ename having (count(ename)>1)

OLEDB Database connection string in C#.Net

OledDb database connections allow C# developers to build data powered applications with Access database. It can be possible with Database connection object and command object. Connection string  For connecting .mdb Access files you can use the following connection string, string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/.Net Project/PharmaERP/PharmaERP/PharmaData.mdb"; and for the Access 2007, 2012,2016 databases you have to use the following one. string connstr = "Provider=Microsoft.ACE.OLEDB.12.0;;Data Source=D:/.Net Project/PharmaERP/pharmaData.accdb;Jet OLEDB:Database Password=password";  Now we are ready to setup the connection, let build the connection objects and get started. Connecting database with OleDbConnection object.     OleDbConnection conn; OleDbCommand Rs; public void Connect() { conn = new OleDbConnection(connstr); conn.Open(); } With the OleDbConnection o...

Copying rows from one Access database to Another using Query

In access database, we can copy rows from one table to another using query. How can we transfer rows from one database to another? Using the in   keyword in Insert statement we can specify an external database path as follows in access query insert into Account_Transactions(Date ,Name ,Type ) in 'D:\Sherpharma\T.mdb' select  Account_Transactions.Date,Account_Transactions.Name,Account_Transactions.Type from  Account_Transactions Here we copy the rows from current database to the T.mdb files. We can also use this query in programming as well.