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
Friday, June 11, 2010
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;
}
Tuesday, May 25, 2010
Merge Cell In DataGridView
To merge Cell in DataGridView You Have to Fire Paint event
after that give the RowHeight and RowWidth and number of cell to be merged
Code is Given below
dataGridView1.Paint += new PaintEventHandler(dataGridView1_Paint);
void dataGridView1_Paint(object sender, PaintEventArgs e)
{
Rectangle rct;
rct = e.ClipRectangle;
rct.X = dataGridView1.GetColumnDisplayRectangle(0, true).X;
rct.Y = dataGridView1.GetRowDisplayRectangle(6, true).Y;//here 6 is the ROW Number which you want to Merge
rct.Height = dataGridView1.Rows[1].Height;//.Cells[0].Size.Height;
rct.Width = dataGridView1.Rows[2].Cells[0].Size.Width * 4;// 4 is the no of cell to be merged
OR
rct.Width = dataGridView1.Width; // its Automatically Merge all the Cell of a ROW
e.Graphics.FillRectangle(Brushes.White, rct);
Pen p = new Pen(SystemColors.ControlDark);
e.Graphics.DrawRectangle(p, rct);
e.Graphics.DrawString("Total Salary " + SalarySum,new System.Drawing.Font("Arial",10,FontStyle.Bold ) ,Brushes.Blue, rct.X, Rect.Y);
}
after that give the RowHeight and RowWidth and number of cell to be merged
Code is Given below
dataGridView1.Paint += new PaintEventHandler(dataGridView1_Paint);
void dataGridView1_Paint(object sender, PaintEventArgs e)
{
Rectangle rct;
rct = e.ClipRectangle;
rct.X = dataGridView1.GetColumnDisplayRectangle(0, true).X;
rct.Y = dataGridView1.GetRowDisplayRectangle(6, true).Y;//here 6 is the ROW Number which you want to Merge
rct.Height = dataGridView1.Rows[1].Height;//.Cells[0].Size.Height;
rct.Width = dataGridView1.Rows[2].Cells[0].Size.Width * 4;// 4 is the no of cell to be merged
OR
rct.Width = dataGridView1.Width; // its Automatically Merge all the Cell of a ROW
e.Graphics.FillRectangle(Brushes.White, rct);
Pen p = new Pen(SystemColors.ControlDark);
e.Graphics.DrawRectangle(p, rct);
e.Graphics.DrawString("Total Salary " + SalarySum,new System.Drawing.Font("Arial",10,FontStyle.Bold ) ,Brushes.Blue, rct.X, Rect.Y);
}
Thursday, May 20, 2010
Bind Data in DataGridView
string strSQLconnection = "Data Source=(local);Initial Catalog=Info;Integrated Security=True";
SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
SqlCommand sqlCommand = new SqlCommand("select * from product", sqlConnection);
sqlConnection.Open();
SqlDataAdapter sda = new SqlDataAdapter(sqlCommand.CommandText, sqlConnection);
DataSet ds = new DataSet();
sda.Fill(ds);
DataGrid1.DataSource = ds.Tables[0];
SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
SqlCommand sqlCommand = new SqlCommand("select * from product", sqlConnection);
sqlConnection.Open();
SqlDataAdapter sda = new SqlDataAdapter(sqlCommand.CommandText, sqlConnection);
DataSet ds = new DataSet();
sda.Fill(ds);
DataGrid1.DataSource = ds.Tables[0];
Tuesday, May 18, 2010
How To Change Localization of Window Application in C#
To Change localization
Take a Combo Box and add item
Hindi
English
Chinese
suppose there is a Label1 on the Form and its Text Property is= Nagendra
and we want to change its Culture according To Language in
Hindi= नागेन्द्र
Chinies=納根德拉
To do this go on the form and set its Property Localizable =True
Now set the language of Form is Hindi and set Label1.text= नागेन्द्र
Now a new .resx file will be made like Form1.hi.resx

Now set the language of Form is Chinies and set Label1.text=納根德拉
Now a new .resx file will be made like Form1.zh-CHT.resx
private void ChangeLanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 0)
{
ChangeLanguage("hi");
}
if (comboBox1.SelectedIndex == 1)
{
ChangeLanguage("en");
}
else if(comboBox1.SelectedIndex==2)
{
ChangeLanguage("zh-CHT");
}
}
Here we have used hi is for Hindi,zh-CHT for Chinies it is specific for every Language
Take a Combo Box and add item
Hindi
English
Chinese
suppose there is a Label1 on the Form and its Text Property is= Nagendra
and we want to change its Culture according To Language in
Hindi= नागेन्द्र
Chinies=納根德拉
To do this go on the form and set its Property Localizable =True
Now set the language of Form is Hindi and set Label1.text= नागेन्द्र
Now a new .resx file will be made like Form1.hi.resx

Now set the language of Form is Chinies and set Label1.text=納根德拉
Now a new .resx file will be made like Form1.zh-CHT.resx
private void ChangeLanguage(string lang)
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(c, c.Name, new CultureInfo(lang));
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 0)
{
ChangeLanguage("hi");
}
if (comboBox1.SelectedIndex == 1)
{
ChangeLanguage("en");
}
else if(comboBox1.SelectedIndex==2)
{
ChangeLanguage("zh-CHT");
}
}
Here we have used hi is for Hindi,zh-CHT for Chinies it is specific for every Language
Thursday, April 8, 2010
Generate random numbers who's sum is a pre-determined
Here We want to generate a 9 digit unique no that is divisible by 9 or multiple of 9
here starting no is 700000002 sum : 7+0+0+0+0+0+0+0+2 =9 and its sum is multiple of 9
suppose you want to generate a no whose starting no is 712 then 712000008 sum=7+1+2+0+0+0+0+0+8=18
now find max no from database and add it
{
// XPCollection XPDomain = new XPCollection(ObjectSpace.Session);
//var a = XPDomain.Select(c => c.UniqueNo).Max();
int a;
select a= max(srno) from Table
int b = Convert.ToInt32(a);
GetUnique(b);
ObjectSpace.CommitChanges();
View.Refresh();
}
public void GetUnique(int MaxNo)
{
int PreviousNo = MaxNo;
for (int a = 0; a <= 1000; a++)
{
if (PreviousNo == 0)
{
DomainObject1 dm = new DomainObject1(ObjectSpace.Session);
dm.UniqueNo = "700000002";
PreviousNo = Convert.ToInt32(dm.UniqueNo);
dm.Save();
}
else
{
DomainObject1 dm = new DomainObject1(ObjectSpace.Session);
dm.UniqueNo =Convert.ToString (PreviousNo + 9);
PreviousNo = Convert.ToInt32(dm.UniqueNo);
dm.Save();
}
}
}
here starting no is 700000002 sum : 7+0+0+0+0+0+0+0+2 =9 and its sum is multiple of 9
suppose you want to generate a no whose starting no is 712 then 712000008 sum=7+1+2+0+0+0+0+0+8=18
now find max no from database and add it
{
// XPCollection
//var a = XPDomain.Select(c => c.UniqueNo).Max();
int a;
select a= max(srno) from Table
int b = Convert.ToInt32(a);
GetUnique(b);
ObjectSpace.CommitChanges();
View.Refresh();
}
public void GetUnique(int MaxNo)
{
int PreviousNo = MaxNo;
for (int a = 0; a <= 1000; a++)
{
if (PreviousNo == 0)
{
DomainObject1 dm = new DomainObject1(ObjectSpace.Session);
dm.UniqueNo = "700000002";
PreviousNo = Convert.ToInt32(dm.UniqueNo);
dm.Save();
}
else
{
DomainObject1 dm = new DomainObject1(ObjectSpace.Session);
dm.UniqueNo =Convert.ToString (PreviousNo + 9);
PreviousNo = Convert.ToInt32(dm.UniqueNo);
dm.Save();
}
}
}
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...
-
Angular is a JavaScript open-source front-end web application framework. Learn and Start Angular 6 https://youtu.be/iCczsazLY-E ...
-
SortingCollection sc = new SortingCollection(); sc.Add (new SortProperty("field on which you want to sort",DevExpress.Xpo.DB.Sorti...
-
Build Angular App for Production while you plan for production release then keep these things in Mind ng build --prod --base--hre...
