Run this qry in SQL :
declare @random varchar(50)
set @random = newid()
print (@random)
select substring(@random,1, 16)
Tuesday, June 30, 2009
Wednesday, June 24, 2009
Difference Between DDL, DML, DCL and TCL
Data Definition Language (DDL) statements are used to define the database structure or schema. Some examples:
CREATE - to create objects in the database
ALTER - alters the structure of the database
DROP - delete objects from the database
TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
COMMENT - add comments to the data dictionary
RENAME - rename an object
Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:
SELECT - retrieve data from the a database
INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - deletes all records from a table, the space for the records remain
MERGE - UPSERT operation (insert or update)
CALL - call a PL/SQL or Java subprogram
EXPLAIN PLAN - explain access path to data
LOCK TABLE - control concurrency
Data Control Language (DCL) statements. Some examples:
GRANT - gives user's access privileges to database
REVOKE - withdraw access privileges given with the GRANT command
Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.
COMMIT - save work done
SAVEPOINT - identify a point in a transaction to which you can later roll back
ROLLBACK - restore database to original since the last COMMIT
SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use
CREATE - to create objects in the database
ALTER - alters the structure of the database
DROP - delete objects from the database
TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed
COMMENT - add comments to the data dictionary
RENAME - rename an object
Data Manipulation Language (DML) statements are used for managing data within schema objects. Some examples:
SELECT - retrieve data from the a database
INSERT - insert data into a table
UPDATE - updates existing data within a table
DELETE - deletes all records from a table, the space for the records remain
MERGE - UPSERT operation (insert or update)
CALL - call a PL/SQL or Java subprogram
EXPLAIN PLAN - explain access path to data
LOCK TABLE - control concurrency
Data Control Language (DCL) statements. Some examples:
GRANT - gives user's access privileges to database
REVOKE - withdraw access privileges given with the GRANT command
Transaction Control (TCL) statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.
COMMIT - save work done
SAVEPOINT - identify a point in a transaction to which you can later roll back
ROLLBACK - restore database to original since the last COMMIT
SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use
Monday, June 22, 2009
Clear the Controls Data on Click of Reset Button
I have 20 controls on my web page. I want to clear the controls data when onclick of reset button:
private void ClearControls(Control parent)
{
foreach (Control _ChildControl in parent.Controls)
{
if ((_ChildControl.Controls.Count > 0))
{
ClearControls(_ChildControl);
}
else
{
if (_ChildControl is TextBox)
{
((TextBox)_ChildControl).Text = string.Empty;
}
else
if (_ChildControl is CheckBox)
{
((CheckBox)_ChildControl).Checked = false;
}
else
if (_ChildControl is DropDownList)
{
((DropDownList)_ChildControl).SelectedIndex = 0;
}
else
if (_ChildControl is ListBox)
{
((ListBox)_ChildControl).SelectedIndex = 0;
}
}
}
}
calling this function like click of reset button ClearControls(this.Page);
private void ClearControls(Control parent)
{
foreach (Control _ChildControl in parent.Controls)
{
if ((_ChildControl.Controls.Count > 0))
{
ClearControls(_ChildControl);
}
else
{
if (_ChildControl is TextBox)
{
((TextBox)_ChildControl).Text = string.Empty;
}
else
if (_ChildControl is CheckBox)
{
((CheckBox)_ChildControl).Checked = false;
}
else
if (_ChildControl is DropDownList)
{
((DropDownList)_ChildControl).SelectedIndex = 0;
}
else
if (_ChildControl is ListBox)
{
((ListBox)_ChildControl).SelectedIndex = 0;
}
}
}
}
calling this function like click of reset button ClearControls(this.Page);
Friday, June 12, 2009
Change Color Of Gridview On Mouse-Over
protected void gridRole_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';this.style.background='#E2DED6';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';this.style.background='none';";
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';this.style.background='#E2DED6';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';this.style.background='none';";
}
}
Tuesday, June 2, 2009
Gridview Selected index change
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
int i = Convert.ToInt32(e.NewSelectedIndex);
GridViewRow row = GridView1.Rows[e.NewSelectedIndex];
Label LocationId = (Label)row.FindControl("LblLocationID");
Label MasterId = (Label)row.FindControl("LblMasterID");
Response.Write("script window.opener.parent.location='locationeditnew.aspx?location_id=" + Server.UrlEncode(LocationId.Text) + "&masterid=" + Server.UrlEncode(MasterId.Text) + "';this.close();/script");
}
{
int i = Convert.ToInt32(e.NewSelectedIndex);
GridViewRow row = GridView1.Rows[e.NewSelectedIndex];
Label LocationId = (Label)row.FindControl("LblLocationID");
Label MasterId = (Label)row.FindControl("LblMasterID");
Response.Write("script window.opener.parent.location='locationeditnew.aspx?location_id=" + Server.UrlEncode(LocationId.Text) + "&masterid=" + Server.UrlEncode(MasterId.Text) + "';this.close();/script");
}
Show Gridview Row in Red Color on the basis of Inner Value
Write following code in Design:
asp:TemplateField HeaderText="Status"
ItemTemplate
asp:Label ID="Lblstatus" runat="server" Text='%# Eval("status") %'/asp:Label
/ItemTemplate
/asp:TemplateField
Write following code in .cs file:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lbl = (Label)e.Row.FindControl("Lblstatus");
if ((string)DataBinder.Eval(e.Row.DataItem, "status").ToString().ToUpper() == "D")
{
e.Row.BackColor = System.Drawing.Color.Red;
e.Row.Font.Bold = true;
}
}
}
asp:TemplateField HeaderText="Status"
ItemTemplate
asp:Label ID="Lblstatus" runat="server" Text='%# Eval("status") %'/asp:Label
/ItemTemplate
/asp:TemplateField
Write following code in .cs file:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lbl = (Label)e.Row.FindControl("Lblstatus");
if ((string)DataBinder.Eval(e.Row.DataItem, "status").ToString().ToUpper() == "D")
{
e.Row.BackColor = System.Drawing.Color.Red;
e.Row.Font.Bold = true;
}
}
}
Subscribe to:
Posts (Atom)