Tuesday, March 16, 2010
Case sensitive column contents in SqlServer
Use the following t-sql code to make the contents of a column case sensitive regardless of the default db setting:
alter table TheTableName alter column TheColumnName TypeOfColEgVarchar(20)OrChar(6) collate Latin1_General_CS_AS
for example:
alter table People alter column LastName varchar(20) collate Latin1_General_CS_AS
Am using this in SqlServer 2005.
alter table TheTableName alter column TheColumnName TypeOfColEgVarchar(20)OrChar(6) collate Latin1_General_CS_AS
for example:
alter table People alter column LastName varchar(20) collate Latin1_General_CS_AS
Am using this in SqlServer 2005.
Thursday, January 28, 2010
Leading zeros in tsql
select right ('StringOfZerosAsManyAsMaxNeededMoreIsOK'
+ cast ( AnIntegerLiteralOrIntVariable as varchar)
, IntLiteralWhichIsTotalLengthOfNeededString)
declare @counter int
set @counter = 126
select right ('000000' + cast ( @counter as varchar) , 6 )
result:
000126
declare @counter int
set @counter = 12345678
select right ('000000000' + cast ( @counter as varchar) , 6 )
result:
345678
declare @counter int
set @counter = 123
select right ('00' + cast ( @counter as varchar) , 6 )
result:
00123
declare @counter int
set @counter = 123
select right ('0000' + cast ( 123 as varchar) , 9 )
result:
000126
+ cast ( AnIntegerLiteralOrIntVariable as varchar)
, IntLiteralWhichIsTotalLengthOfNeededString)
declare @counter int
set @counter = 126
select right ('000000' + cast ( @counter as varchar) , 6 )
result:
000126
declare @counter int
set @counter = 12345678
select right ('000000000' + cast ( @counter as varchar) , 6 )
result:
345678
declare @counter int
set @counter = 123
select right ('00' + cast ( @counter as varchar) , 6 )
result:
00123
declare @counter int
set @counter = 123
select right ('0000' + cast ( 123 as varchar) , 9 )
result:
000126
Thursday, January 14, 2010
Crystal Reports like in db selection formula
{vTimeTrackDataAll4.ContactName} like '*'+{?pEmpName}+'*' and
{vTimeTrackDataAll4.StartTime} >= {?pStartDate} and
{vTimeTrackDataAll4.StartTime} <= {?pEndDate}
{vTimeTrackDataAll4.StartTime} >= {?pStartDate} and
{vTimeTrackDataAll4.StartTime} <= {?pEndDate}
Wednesday, January 13, 2010
javascript on mouseover lv and doubleclick event
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
// not uploaded data
// this is done everytime the page is refreshed.
if (e.Item.ItemType == ListViewItemType.DataItem)
{
if (res & e.Row.DataItemIndex == theRowIndex)
{
GridView1.Rows[theRowIndex].Attributes.Add("onmouseover", "this.style.backgroundColor='PeachPuff'");
GridView1.Rows[theRowIndex].Attributes.Add("onmouseout", "this.style.backgroundColor='Beige'");
}
// Get the LinkButton control in the 9th cell
LinkButton _doubleClickButton = (LinkButton)e.Row.Cells[9].Controls[0];
// Get the javascript which is assigned to this LinkButton
string _jsDouble =
ClientScript.GetPostBackClientHyperlink(_doubleClickButton, "");
// Add this JavaScript to the ondblclick Attribute of the row
e.Row.Attributes["ondblclick"] = _jsDouble;
right click already defined
LinkButton _rightClickButton = (LinkButton)e.Row.Cells[10].Controls[0];
Get the javascript which is assigned to this LinkButton
string _jsDouble2 =
ClientScript.GetPostBackClientHyperlink(_rightClickButton, "");
Add this JavaScript to the ondblclick Attribute of the row
e.Row.Attributes["mousemove"] = _jsDouble2;
}
}
{
// not uploaded data
// this is done everytime the page is refreshed.
if (e.Item.ItemType == ListViewItemType.DataItem)
{
if (res & e.Row.DataItemIndex == theRowIndex)
{
GridView1.Rows[theRowIndex].Attributes.Add("onmouseover", "this.style.backgroundColor='PeachPuff'");
GridView1.Rows[theRowIndex].Attributes.Add("onmouseout", "this.style.backgroundColor='Beige'");
}
// Get the LinkButton control in the 9th cell
LinkButton _doubleClickButton = (LinkButton)e.Row.Cells[9].Controls[0];
// Get the javascript which is assigned to this LinkButton
string _jsDouble =
ClientScript.GetPostBackClientHyperlink(_doubleClickButton, "");
// Add this JavaScript to the ondblclick Attribute of the row
e.Row.Attributes["ondblclick"] = _jsDouble;
right click already defined
LinkButton _rightClickButton = (LinkButton)e.Row.Cells[10].Controls[0];
Get the javascript which is assigned to this LinkButton
string _jsDouble2 =
ClientScript.GetPostBackClientHyperlink(_rightClickButton, "");
Add this JavaScript to the ondblclick Attribute of the row
e.Row.Attributes["mousemove"] = _jsDouble2;
}
}
Monday, January 11, 2010
Adding a UserControl to a Placeholder Dynamically
So I was trying to dynamically generate my asp.net page by newing a UserControl and adding it to a Placeholder on Page_Load:
ucSelectMed ucMySelectMed = new ucSelectMed();
phSelectMed.Controls.Add(ucMySelectMed);
Ran the project, nothing was on the page.
Was really confused because the following works:
TextBox tb = new TextBox();
phSelectMed.Controls.Add(tb);
Anyway, what was needed is:
ucSelectMed ucMySelectMed = (ucSelectMed)LoadControl("ucSelectMed.ascx");
phSelectMed.Controls.Add(ucMySelectMed);
ucSelectMed ucMySelectMed = new ucSelectMed();
phSelectMed.Controls.Add(ucMySelectMed);
Ran the project, nothing was on the page.
Was really confused because the following works:
TextBox tb = new TextBox();
phSelectMed.Controls.Add(tb);
Anyway, what was needed is:
ucSelectMed ucMySelectMed = (ucSelectMed)LoadControl("ucSelectMed.ascx");
phSelectMed.Controls.Add(ucMySelectMed);
Monday, January 4, 2010
To Gac or Not To Gac
Gac location is c:\windows\assembly
Best post I have seen on this:
http://justmyopinion.cilyok.net/?p=406
Best post I have seen on this:
http://justmyopinion.cilyok.net/?p=406
Thursday, December 24, 2009
Infragistics WebCombo Get the Value of Cell by Column Name
Get the Value in a Cell by the Column Name
To get the value in a Infragistics WebCombo cell by the column name (in this case, column DrugName):
string chosenName = e.Row.Cells.FromKey("DrugName").ToString;
where e is the EventArgs from
protected void igWebCombo1_SelectedRowChanged(object sender,
Infragistics.WebUI.WebCombo.SelectedRowChangedEventArgs e)
I had previously gotten the value using an index value:
string chosen = e.Row.Cells[2].Value.ToString().Trim();
but in continuing development, the number of columns may vary, and therefore the index may change.
To get the value in a Infragistics WebCombo cell by the column name (in this case, column DrugName):
string chosenName = e.Row.Cells.FromKey("DrugName").ToString;
where e is the EventArgs from
protected void igWebCombo1_SelectedRowChanged(object sender,
Infragistics.WebUI.WebCombo.SelectedRowChangedEventArgs e)
I had previously gotten the value using an index value:
string chosen = e.Row.Cells[2].Value.ToString().Trim();
but in continuing development, the number of columns may vary, and therefore the index may change.
Subscribe to:
Posts (Atom)