Skip to main content

Posts

Example of code of c sharp with SQL Server connectivity

using System; using System.Data; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using System.Drawing; namespace DatabaseExp { public partial class DatabaseExp : Form { SqlConnection conn; SqlDataAdapter adaptr; SqlCommand cmd; DataTable tbl; static int count = 0, current = 0; static int check = 0; public DatabaseExp() { InitializeComponent(); } private void DatabaseExp_Load(object sender, EventArgs e) { string connectionString = null; adaptr = new SqlDataAdapter(); tbl = new DataTable(); connectionString = "Data Source=127.0.0.1;Initial Catalog=Abdul;User ID=sa;Password=allah"; conn = new SqlConnection(connectionString); try { conn.Open(); MessageBox.Show("Connection Open !", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); //conn.Close(); } catch (Exception ex) { Message

C sharp Code to Send Email From G Mail to any other mail Address

Bubble sort Algorithm with two dimensional Array using c sharp

In bubble sort algorithm, we pick the two elements of the collection one by one from the start and compare them. If first element is larger than the second element then we swap them, and then continue the procedure till the end of the collection. Like see we have a string array like below string[] str = {"e","c","b","d","a" }; so, first we will pick first two elements and will compare them if(e>c) {  // we will swap both the elements.  // so our array will be like this now  str = {"c","e","b","d","a" }; } In next step we will pick the elements e , b and will compare them same rule will apply on it. If firs one will be greater then the second one then we will swap them then the array will be look like this: str = {"c","b","e","d","a" }; we will continue the process until we got the whole array in the sorted form. c

Know that Truncate is DML or DDL in SQL

These are some reason why truncate is ddl not dml 1. TRUNCATE can change storage parameters (the NEXT parameter), and those are part of the object definition - that's in the DDL commands. ... 2. TRUNCATE does an implicit commit, and cannot be rolled back most DDL operations in Oracle do this, no DML does.that's Truncate is DDL 3. TRUNCATE TABLE handles table as an entity to clear all data from the specified table 4. Deallocates all space used by the removed rows make truncate to DDL 5. The fact that TRUNCATE doesn't run ON DELETE triggers also sets it apart from normal DML operations (but some DML operations also skip triggers, so that's not a clear indicator. As TRUNCATE removes all rows, it can theoretically be implemented by dropping the table and recreating it in which case it is like any other DDL statement The statement is not expected to be used for usual transactions where insert,update,delete and select statements are used.It is mainly meant for

Example of rollup and cube in sql

SQL> SELECT DEPTNO,SUM(SAL)  2 FROM EMP  3 GROUP BY ROLLUP(DEPTNO)  4 /  DEPTNO SUM(SAL) ---------- ----------  10 8750  20 10875  30 9400  29025 SQL> ED Wrote file afiedt.buf  1 SELECT NVL(TO_CHAR(DEPTNO),'TOTAL'),SUM(SAL)  2 FROM EMP  3* GROUP BY ROLLUP(DEPTNO) SQL> / NVL(TO_CHAR(DEPTNO),'TOTAL') SUM(SAL) ---------------------------------------- ---------- 10 8750 20 10875 30 9400 TOTAL 29025 SQL> ED Wrote file afiedt.buf  1 SELECT NVL(TO_CHAR(DEPTNO),'TOTAL'),SUM(SAL)  2 FROM EMP  3* GROUP BY CUBE(DEPTNO) SQL> / NVL(TO_CHAR(DEPTNO),'TOTAL') SUM(SAL) ---------------------------------------- ---------- TOTAL 29025 10 8750 20 10875 30 9400 SQL> ED Wrote file afiedt.buf  1 SELECT NVL(TO_CHAR(DEPTNO),'TOTAL'),JOB,SUM(SAL)  2 FROM EMP  3* GROUP BY ROLLUP(DEPTNO,JOB) SQL> / NVL(TO_CHAR(DEPTNO),'TOTAL') JOB SUM(SAL) ---------------------------------------- --------- ---------- 10 CLERK 1300 10 MANAGER 2450 10 PR

Ways to Tune the Queries in SQL and Type of Indexes

There are many methods to tune up a query. 1) using EXPLAIN_PLAN. 2) using AUTOTRACE and set Timing ON. 3) tkprof 4) Indexes 5) Cost- based Optimisation 6) Analyze command. 7) parallel query option. Types of indexes B-tree Bitmap Hash Index-organized table Reverse key Function-based Partitioned (local and global) Bitmap join indexes

Difference in length between the first biggest and the second biggest name in sql table

to get difference in length between the first biggest and the second biggest name in SQL table like Employees table. You can try following query to get the same. 1. SELECT MAX(DECODE(DR, 1, L, NULL)) - MAX(DECODE(DR, 2, L, NULL)) AS DIFF FROM ( SELECT LENGTH(FIRST_NAME||LAST_NAME) AS L, DENSE_RANK() OVER(ORDER BY LENGTH(FIRST_NAME||LAST_NAME) DESC) AS DR FROM EMPLOYEES ) WHERE DR IN (1, 2) 2.select max(a) - min(a)from ( select distinct(length(FIRST_NAME)) a from EMPLOYEES order by length(FIRST_NAME) desc) where rownum < 3