insert into Emp(name,age) values(EncryptByPassPhrase('20','aarti'),50)
select id, DECRYPTBYPASSPHRASE('20',name) "Name" from Emp
Thursday, July 22, 2010
Wednesday, July 21, 2010
Procedure in SQL Server
Create PROCEDURE ins
@name varchar(50),
@age float
as
insert into Emp(name,age) values(@name,@age)
Execute Procedure
ins 'Raj',22
@name varchar(50),
@age float
as
insert into Emp(name,age) values(@name,@age)
Execute Procedure
ins 'Raj',22
Tuesday, July 20, 2010
Insert Update Delete Through Linq in C#
take a Window Form Application
add a Class LINQ to SQL Classes named DataClasses1.dbml
now Double Click on DataClasses1.dbml it Design View will be open
now on it Give Database Conection and drag Table on Designer
Now make a object of DataClasses1DataContext Class and access all Clases
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Linq;
namespace LinqImplementation
{
public partial class Form1 : Form
{
DataClasses1DataContext dc1 = null;
string ss = null;
public Form1()
{
InitializeComponent();
ss = "Data Source=(local);Initial Catalog=EMP;Integrated Security=SSPI;";
dc1 = new DataClasses1DataContext(ss);
}
private void btnSelect_Click(object sender, EventArgs e)
{
var q = from a in dc1.GetTable()
where a.ClientName.Contains("aj")
a.Salary == 20000
select a;
dataGridView1.DataSource = q;
}
private void btnSave_Click(object sender, EventArgs e)
{
try
{
Table XPCClient = dc1.GetTable();
Client cl = new Client();
cl.Oid = Guid.NewGuid();
cl.ClientName = txtclientname.Text;
cl.Salary = int.Parse(txtsalary.Text);
cl.SEX = cmbsex.SelectedIndex;
XPCClient.InsertOnSubmit(cl);
XPCClient.Context.SubmitChanges();
MessageBox.Show("Record Inserted Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message+"Record Insertion Failed");
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
Table XpCClient = dc1.GetTable();
var obj = (from w in XpCClient
where w.Salary == 12000
select w).FirstOrDefault();
var obj1 = XpCClient.Where(a => a.Salary == 20000).FirstOrDefault();
XpCClient.DeleteOnSubmit(obj);
XpCClient.Context.SubmitChanges();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
Table XPCClient = dc1.GetTable();
var obj = from a in XPCClient
where a.Salary == Convert.ToInt32(txtsalary.Text)
select a;
Client obj1 = (from ab in XPCClient
where ab.Salary == Convert.ToInt32(txtsalary.Text)
select ab).FirstOrDefault();
if (obj == null)
MessageBox.Show("Record Not Found");
else
{
foreach (Client c in obj)
{
c.Salary = 55000;
dc1.SubmitChanges();
}
}
}
}
}
Note : Client is a Table in EMP Database
add a Class LINQ to SQL Classes named DataClasses1.dbml
now Double Click on DataClasses1.dbml it Design View will be open
now on it Give Database Conection and drag Table on Designer
Now make a object of DataClasses1DataContext Class and access all Clases
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Linq;
namespace LinqImplementation
{
public partial class Form1 : Form
{
DataClasses1DataContext dc1 = null;
string ss = null;
public Form1()
{
InitializeComponent();
ss = "Data Source=(local);Initial Catalog=EMP;Integrated Security=SSPI;";
dc1 = new DataClasses1DataContext(ss);
}
private void btnSelect_Click(object sender, EventArgs e)
{
var q = from a in dc1.GetTable
where a.ClientName.Contains("aj")
a.Salary == 20000
select a;
dataGridView1.DataSource = q;
}
private void btnSave_Click(object sender, EventArgs e)
{
try
{
Table
Client cl = new Client();
cl.Oid = Guid.NewGuid();
cl.ClientName = txtclientname.Text;
cl.Salary = int.Parse(txtsalary.Text);
cl.SEX = cmbsex.SelectedIndex;
XPCClient.InsertOnSubmit(cl);
XPCClient.Context.SubmitChanges();
MessageBox.Show("Record Inserted Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message+"Record Insertion Failed");
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
Table
var obj = (from w in XpCClient
where w.Salary == 12000
select w).FirstOrDefault();
var obj1 = XpCClient.Where(a => a.Salary == 20000).FirstOrDefault();
XpCClient.DeleteOnSubmit(obj);
XpCClient.Context.SubmitChanges();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
Table
var obj = from a in XPCClient
where a.Salary == Convert.ToInt32(txtsalary.Text)
select a;
Client obj1 = (from ab in XPCClient
where ab.Salary == Convert.ToInt32(txtsalary.Text)
select ab).FirstOrDefault();
if (obj == null)
MessageBox.Show("Record Not Found");
else
{
foreach (Client c in obj)
{
c.Salary = 55000;
dc1.SubmitChanges();
}
}
}
}
}
Note : Client is a Table in EMP Database
Insert Update Delete Through Linq in C#
take a Window Form Application
add a Class LINQ to SQL Classes named DataClasses1.dbml
now Double Click on DataClasses1.dbml it Design View will be open
now on it Give Database Conection and drag Table on Designer
Now make a object of DataClasses1DataContext Class and access all Clases
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Linq;
namespace LinqImplementation
{
public partial class Form1 : Form
{
DataClasses1DataContext dc1 = null;
string ss = null;
public Form1()
{
InitializeComponent();
ss = "Data Source=(local);Initial Catalog=EMP;Integrated Security=SSPI;";
dc1 = new DataClasses1DataContext(ss);
}
private void btnSelect_Click(object sender, EventArgs e)
{
var q = from a in dc1.GetTable()
where a.ClientName.Contains("aj")
a.Salary == 20000
select a;
dataGridView1.DataSource = q;
}
private void btnSave_Click(object sender, EventArgs e)
{
try
{
Table XPCClient = dc1.GetTable();
Client cl = new Client();
cl.Oid = Guid.NewGuid();
cl.ClientName = txtclientname.Text;
cl.Salary = int.Parse(txtsalary.Text);
cl.SEX = cmbsex.SelectedIndex;
XPCClient.InsertOnSubmit(cl);
XPCClient.Context.SubmitChanges();
MessageBox.Show("Record Inserted Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message+"Record Insertion Failed");
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
Table XpCClient = dc1.GetTable();
var obj = (from w in XpCClient
where w.Salary == 12000
select w).FirstOrDefault();
var obj1 = XpCClient.Where(a => a.Salary == 20000).FirstOrDefault();
XpCClient.DeleteOnSubmit(obj);
XpCClient.Context.SubmitChanges();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
Table XPCClient = dc1.GetTable();
var obj = from a in XPCClient
where a.Salary == Convert.ToInt32(txtsalary.Text)
select a;
Client obj1 = (from ab in XPCClient
where ab.Salary == Convert.ToInt32(txtsalary.Text)
select ab).FirstOrDefault();
if (obj == null)
MessageBox.Show("Record Not Found");
else
{
foreach (Client c in obj)
{
c.Salary = 55000;
dc1.SubmitChanges();
}
}
}
}
}
Note : Client is a Table in EMP Database
add a Class LINQ to SQL Classes named DataClasses1.dbml
now Double Click on DataClasses1.dbml it Design View will be open
now on it Give Database Conection and drag Table on Designer
Now make a object of DataClasses1DataContext Class and access all Clases
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Linq;
namespace LinqImplementation
{
public partial class Form1 : Form
{
DataClasses1DataContext dc1 = null;
string ss = null;
public Form1()
{
InitializeComponent();
ss = "Data Source=(local);Initial Catalog=EMP;Integrated Security=SSPI;";
dc1 = new DataClasses1DataContext(ss);
}
private void btnSelect_Click(object sender, EventArgs e)
{
var q = from a in dc1.GetTable
where a.ClientName.Contains("aj")
a.Salary == 20000
select a;
dataGridView1.DataSource = q;
}
private void btnSave_Click(object sender, EventArgs e)
{
try
{
Table
Client cl = new Client();
cl.Oid = Guid.NewGuid();
cl.ClientName = txtclientname.Text;
cl.Salary = int.Parse(txtsalary.Text);
cl.SEX = cmbsex.SelectedIndex;
XPCClient.InsertOnSubmit(cl);
XPCClient.Context.SubmitChanges();
MessageBox.Show("Record Inserted Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message+"Record Insertion Failed");
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
Table
var obj = (from w in XpCClient
where w.Salary == 12000
select w).FirstOrDefault();
var obj1 = XpCClient.Where(a => a.Salary == 20000).FirstOrDefault();
XpCClient.DeleteOnSubmit(obj);
XpCClient.Context.SubmitChanges();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
Table
var obj = from a in XPCClient
where a.Salary == Convert.ToInt32(txtsalary.Text)
select a;
Client obj1 = (from ab in XPCClient
where ab.Salary == Convert.ToInt32(txtsalary.Text)
select ab).FirstOrDefault();
if (obj == null)
MessageBox.Show("Record Not Found");
else
{
foreach (Client c in obj)
{
c.Salary = 55000;
dc1.SubmitChanges();
}
}
}
}
}
Note : Client is a Table in EMP Database
Friday, June 11, 2010
Find all Database in sql server 2005
select * from sys.databases
select * from sys.tables
To see all the column of table
select * from sys.all_columns where [object_id]= OBJECT_ID (N'dbo.emp')//Emp is table name
select * from sys.tables
To see all the column of table
select * from sys.all_columns where [object_id]= OBJECT_ID (N'dbo.emp')//Emp is table name
Wednesday, June 9, 2010
Change Text/Image Periodically in Windo application in C#
I have taken a Window Form and add a Label
and a Timer I want Label text should be
change after 5 second
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Timer tm = new Timer();
tm.Tick += new EventHandler(tm_Tick);
tm.Interval = (1000) * (3);
tm.Enabled = true;
tm.Start();
}
int i = 0;
void tm_Tick(object sender, EventArgs e)
{
i++;
Timer tm = (Timer)sender;
if (i == 1)
label1.Text = "NSE";
else if (i == 2)
label1.Text = "BSE";
else if (i == 3)
{
label1.Text = "NCDX";
}
else if (i == 4)
{
label1.Text = "MCX";
i = 0;
}
}
}
and a Timer I want Label text should be
change after 5 second
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Timer tm = new Timer();
tm.Tick += new EventHandler(tm_Tick);
tm.Interval = (1000) * (3);
tm.Enabled = true;
tm.Start();
}
int i = 0;
void tm_Tick(object sender, EventArgs e)
{
i++;
Timer tm = (Timer)sender;
if (i == 1)
label1.Text = "NSE";
else if (i == 2)
label1.Text = "BSE";
else if (i == 3)
{
label1.Text = "NCDX";
}
else if (i == 4)
{
label1.Text = "MCX";
i = 0;
}
}
}
Tuesday, June 1, 2010
Auto Complete Option in ComboBox in C#
ArrayList ObjArrayList=new ArrayList():
private void Form_Load(object sender, EventArgs e)
{
ObjArrayList.Add("a");
ObjArrayList.Add("aa");
ObjArrayList.Add("b");
ObjArrayList.Add("bb");
ObjArrayList.Add("c");
ObjArrayList.Add("cc");
ObjArrayList.Add("d");
ObjArrayList.Add("dd");
OR
cmbSymbol.DataSource = ObjArrayList;// You can Give DataSource Also
ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
ComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
AutoCompleteStringCollection dataSymbols = new AutoCompleteStringCollection();
for (int i = 0; i < ObjArrayList.Count; i++)//If You are using DataSet then user Ds.Tables[0].Rows.Count
{
dataSymbols.Add(ObjArrayList[i].ToString());
}
ComboBox1.AutoCompleteCustomSource = dataSymbols;
}
private void Form_Load(object sender, EventArgs e)
{
ObjArrayList.Add("a");
ObjArrayList.Add("aa");
ObjArrayList.Add("b");
ObjArrayList.Add("bb");
ObjArrayList.Add("c");
ObjArrayList.Add("cc");
ObjArrayList.Add("d");
ObjArrayList.Add("dd");
OR
cmbSymbol.DataSource = ObjArrayList;// You can Give DataSource Also
ComboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
ComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
AutoCompleteStringCollection dataSymbols = new AutoCompleteStringCollection();
for (int i = 0; i < ObjArrayList.Count; i++)//If You are using DataSet then user Ds.Tables[0].Rows.Count
{
dataSymbols.Add(ObjArrayList[i].ToString());
}
ComboBox1.AutoCompleteCustomSource = dataSymbols;
}
Subscribe to:
Posts (Atom)
Mat Table Angular
Mat Table in Angular Mat table is used to display data . its a material designed styled data-table . For using Material Table MatTableMo...
-
SortingCollection sc = new SortingCollection(); sc.Add (new SortProperty("field on which you want to sort",DevExpress.Xpo.DB.Sorti...
-
Angular is a JavaScript open-source front-end web application framework. Learn and Start Angular 6 https://youtu.be/iCczsazLY-E ...
-
Build Angular App for Production while you plan for production release then keep these things in Mind ng build --prod --base--hre...