Friday, July 24, 2009
Monday, July 06, 2009
lost designer.aspx in asp.net web application
to fix it, right click on the aspx page in solution explorer and select Convert to Web Application"
Posted by
SF
at
3:36 pm
0
comments
RadGrid: rebind detailtable after command execution
e.Item.OwnerTableView.Rebind();
this only rebinds the detailtable, so the current expanding status will remain.
Posted by
SF
at
11:17 am
0
comments
Friday, July 03, 2009
fetch the record primary key from MasterTable while using FormTemplate for insert and update
when you have a FormTemplate for insert and update in RadGrid.MasterTable, there is no commangArgument, therefore the record's primary key can not be passed on using commandargument.
This can be done by
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "Update")
{
int RecordId= Convert.ToInt32(RadGrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["RecordId"].ToString());
}
}
Posted by
SF
at
4:21 pm
0
comments
Thursday, July 02, 2009
RadGrid: rebind detailtable from external event
protected void ReBindExpandedDetailTable()
{
foreach (GridDataItem item in RadGrid1.Items)
{
string aaaValueString= item.GetDataKeyValue("aaa").ToString();
if (aaaValueString==
{
if (item.Expanded == true)
{
GridTableView nestedView = ((GridDataItem)item).ChildItem.NestedTableViews[0];
nestedView.Rebind();
}
}
}
}
Posted by
SF
at
2:16 pm
0
comments
RadGrid: hide add new and refresh buttons from code behind
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridCommandItem)
{
GridCommandItem cmditm = (GridCommandItem)e.Item;
//to hide AddNewRecord button
cmditm.FindControl("InitInsertButton").Visible = false;//hide the text
cmditm.FindControl("AddNewRecordButton").Visible = false;//hide the image
//to hide Refresh button
cmditm.FindControl("RefreshButton").Visible = false;//hide the text
cmditm.FindControl("RebindGridButton").Visible = false;//hide the image
}
}
Posted by
SF
at
12:40 pm
6
comments
RadGrid: problem displaying bool value in formtemplate type edit form insert mode
I was able to update any records in the grid. However when I clicked on Add New Record, I received an error "specified cast is not valid" on the boolean field "IsActive".
see code below for my ASPX page content
The solution is:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
GridEditCommandColumn editColumn = (GridEditCommandColumn)rgQualificationList.MasterTableView.GetColumn("EditCommandColumn");
editColumn.Visible = false;
e.Canceled = true;
//Prepare an IDictionary with the predefined values
System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();
//set initial checked state for the checkbox on init insert
newValues["IsActive"] = false;
//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
}
Posted by
SF
at
12:03 pm
1 comments
Wednesday, July 01, 2009
Display RadGrid row details in AjaxToolkit ModalPopupExtender
found this code library useful
http://www.telerik.com/community/code-library/aspnet-ajax/grid/display-radgrid-row-details-in-ajaxtoolkit-modalpopupextender.aspx
Posted by
SF
at
12:50 pm
0
comments
Thursday, June 18, 2009
show or hide nested table views RadGrid SP1 Q1 2009
protected void ShowOrHideNestedTableView()
{
foreach (GridDataItem CS in rgABC.Items)
{
if (CS.OwnerTableView.Name == "AAA")
{
if (cb123.Checked)
{
CS.Parent.Visible = true;
CS.Visible = true;
}
else
{
CS.Parent.Visible = false;
CS.Visible = false;
}
}
}
}
protected void rgScheduleList_PreRender(object sender, EventArgs e)
{
ShowOrHideNestedTableView();
}
Posted by
SF
at
3:35 pm
0
comments
Wednesday, June 17, 2009
aspx c# open new window in button click event when the button is placed inside an ajax update panel
val1 is an integer
val2 is a boolean
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("window.open(abc.aspx?val1=" + val1Value.ToString() + "');");
ScriptManager.RegisterClientScriptBlock(this.upd1, this.upd1.GetType(), "abc", sb.ToString(), true);
Posted by
SF
at
2:59 pm
2
comments
aspx passing on multiple parameter values in URL
val1 is an integer
val2 is a boolean
in page 1:
aspx:
c#:
RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("xxx('" + val1+ "',true);");
in page 2
c#
if (!string.IsNullOrEmpty(Request["val2"]))
{
if (bool.Parse(Request["val2"]))
----logic here---------
}
if (!string.IsNullOrEmpty(Request["val1"]))
{
if (int.Parse(Request["val1"])>0)
----logic here---------
}
Posted by
SF
at
2:46 pm
0
comments
Thursday, June 04, 2009
COALESCE
use COALESCE to manage a nullable db value, reference:
http://msdn.microsoft.com/en-us/library/ms190349.aspx
Posted by
SF
at
3:50 pm
0
comments
Monday, May 25, 2009
Error: Could not load file or assembly 'Telerik.Web.UI, Version=2009.1.402
Error: Could not load file or assembly 'Telerik.Web.UI, Version=2009.1.402.X, Culture=neutral, PublicKeyToken=XXXX' or one of its dependencies
Found some useful sources here:
This is the one helped me to solve my problem
Another one here
one more
Another one here Here
Posted by
SF
at
5:45 pm
0
comments
Friday, May 22, 2009
making radgrid filters case insensitive
GroupingSettings-CaseSensitive="false"
Posted by
SF
at
5:22 pm
0
comments
Friday, May 01, 2009
locate and hide BoundField in gridview asp.net c#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ABC")) == "Text To Be Found")
e.Row.Visible = false;
}
}
Posted by
SF
at
3:11 pm
0
comments
Friday, April 17, 2009
RadGrid hide column in export
RadGrid1.MasterTableView.Columns.FindByUniqueName("ABC").Visible = false;
Posted by
SF
at
3:13 pm
0
comments
sorting problem - RadGrid GridTemplateColumn
my code that has problem sorting template columns:
the instruction says "the SortExpression value should match the data field you want to sort on (typically the field a control in the template is bound to)". I made sure this rule is applied but the problem remained. Then I removed the HeaderTemplate components, instead I added value to HeaderText property in the GridTemplateColumn level. This solved the problem, not sure why though.....
the new code looks like:
...........
.......
Posted by
SF
at
2:11 pm
0
comments
Wednesday, April 15, 2009
RadGrid Insert UserControl does not close automatically after insert
protected void ABC_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e){if (e.CommandName == "PerformInsert"){//make sure the insert user control closes automatically after insertede.Item.OwnerTableView.IsItemInserted = false;}}
Posted by
SF
at
2:06 pm
0
comments
Tuesday, April 14, 2009
ASP.NET How to deal with the message: error connecting to undo manager of source file "........"
* Delete the .designer.cs file
* convert the .aspx or ascx file into a webapplication by right clicking on it
Posted by
SF
at
5:45 pm
0
comments
Checked=' < % # DataBinder.Eval( Container, "DataItem.Active" ) % >'
Posted by
SF
at
4:22 pm
0
comments
Friday, April 03, 2009
pre-populate value into RadGrid Insert
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
//enter the code here
}
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormInsertItem && RadGrid1.MasterTableView.IsItemInserted)
{
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
(insertItem["abc"].Controls[0] as TextBox).Text = "hello world";
}
}
Posted by
SF
at
9:23 am
0
comments
Monday, February 16, 2009
Visual Studio 2005 bug in ASP.NET applications
my web.config has multiple connection strings.
when I right click on a table adapter in a dataset in design view, select "configure...", the dataset configuration window pops up. Naturally you'd just make the changes that you want to the query and click on Finish. If this table adapter doesn't use the first connection string listed in the web.config, visual studio will automatically change the connection string to the first one listed in the web.config.
In order to fix the problem when you first open up the configuration window click on Previous to go back to the connection string selection view, RESELECT the connection string. If you happened to encounter this error until this stage right click on the empty area of the dataset design view and select View Code. Then delete the unused connection string.
Posted by
SF
at
11:23 am
1 comments
Wednesday, February 04, 2009
ipconfig not working in cmd mode - Vista issue
when i tried to enter ipconfig in cmd mode it says: not valid command.
the solution is: right click on the cmd program and select "run as administrator".
why couldn't Vista run my programs as administrator when i logged in as administrator? this is stupid!
Posted by
SF
at
8:51 am
0
comments
Tuesday, December 23, 2008
Compare mobile phone Cap Plans
found this tool very useful
http://www.mobchoice.com.au/compare-cap-plans-spreadsheet
Posted by
SF
at
9:42 am
0
comments
Wednesday, December 10, 2008
string.format new line partially works (C#, ASP.NET)
see below my code. every "\n" works fine except the ones after "Event: {0}" and "Start Date: {1:D}", basically the Event, Start Date and End Date are printed on same line. can anyone help please? thanks in advance.
string.Format(
"Schedule Details: \n" +
"Event: {0}\n"+
"Start Date: {1:D} \n" +
"End Date: {2:D} \n" +
"Location: {3} \n"
,schedule.event,
schedule.startDate,
schedule.endDate,
schedule.location);
I tried ""Event: {0}"+ Environment.NewLine" and "Event: {0}\r" and "Event: {0}/r/n" got the same result
==============
Schedule Details:
Event: Basketball Match Start Date: Friday, 1 May 2009 End Date: Tuesday, 30 June 2009
Location: Como
================
Then I tried "Event: {0}\n"+ Environment.NewLine" and "Event: {0}\r"+ Environment.NewLine" and "Event: {0}/n/r" got this result (an additional line)
==============
Schedule Details:
Event: Basketball Match
Start Date: Friday, 1 May 2009 End Date: Tuesday, 30 June 2009
Location: Como
================
It seems that it works either for no newline or 2 new lines, but not for 1 newline. I tried to take out "Event" everything else worked just fine, so the problem must be with "Event"?
The Event has datatype of "string", startDate and endDate are datetime, location is string. A sample of Event value is "Attend Class Certificate III in Basketball".
Eventually the problem is solved, not sure why though.....:
I put single quotes around the Event value, not sure how exactly but it worked.
"Event: '{0}'\n"+
Posted by
SF
at
2:10 pm
0
comments
Labels: ASP.NET), new line, partially works (C#, string.format
Tuesday, August 05, 2008
select checkboxlist based on to database data
foreach(datarow in the query result)
{
ListItem currentCheckBox = CheckBoxListABC.Items.FindByValue(datarow ["TheFieldName"].ToString());
if (currentCheckBox != null)
{
currentCheckBox.Selected = true;
}
}
Posted by
SF
at
9:14 am
0
comments
Labels: ASP.NET, checkboxlist, databinding, select
Monday, August 04, 2008
ASP.NET C# capitalize the first letter of a string
using System.Globalization;
..
..
..
..
..
string ManipulatedString= CultureInfo.CurrentCulture.TextInfo.ToTitleCase("OriginalString");
Posted by
SF
at
5:34 pm
0
comments
Labels: ASP.NET, C#, capitalize first letter, titlecase
Saturday, August 02, 2008
"postback" event not related to REVIOUS and NEXT button on Internet Explorer?
in my case PageA has a buttonA that opens PageB. The code is "response.redirect("PageB.aspx");"
on PageB I have some methodM to call under condition "if (!IsPostBack)"
After I clicked on ButtoA to open PageB, methodM is trigerred.
but when I use the PREVIOUS button on Internet Explore to go back to PageA and click on NEXT button to go back to PageB the methodM didn't fire.
How can I catch the Previous and Next button click event?
the answer is adding the code below into Page_Load in the target page, this line of code will force the target page to load from server instead of cache
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Posted by
SF
at
1:00 am
0
comments
Labels: button, IE, ispostback, load from server, next, previous, stop cache
Wednesday, July 30, 2008
a helpful tutorial for Creating a Data Access Layer in VS2005 Express
http://www.asp.net/learn/data-access/tutorial-01-cs.aspx
Posted by
SF
at
8:04 pm
0
comments
Labels: asp.net 2.0, data access, vs2005 express
How to retrieve visitor's IP in C# ASP.NET 2.0
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
return clientIPAddress;
Posted by
SF
at
7:10 pm
0
comments
Labels: 2.0, ASP.NET, C#, retrieve IP
Friday, July 25, 2008
MSSQL LIKE operator work with parameter values
without parameter: LIKE '%abc%'
with parameter: LIKE '%'+@searchString+'%'
Posted by
SF
at
3:53 pm
0
comments
Labels: keyword search, LIKE, MSSQL, operator, parameter
Tuesday, June 17, 2008
useful stuff to solve visual studio 2008 slowness
found these links quite useful:
http://blogs.msdn.com/webdevtools/archive/2008/02/09/downloadable-hotfix-performance-and-editor-fixes-for-microsoft-visual-studio-2008-and-visual-web-developer-express-2008.aspx
https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10826
Posted by
SF
at
5:01 pm
0
comments
Tomorrow's CIO: Are You Ready Today?
found this tool on InformationWeek very interesting:
http://www.informationweek.com/news/management/interviews/showArticle.jhtml?articleID=208403497#sg_wrapper
Posted by
SF
at
4:28 pm
0
comments
Monday, June 09, 2008
Cannot open .zip file in WSS 3.0
found solution for this problem on Microsoft
http://support.microsoft.com/kb/841120
Posted by
SF
at
2:23 pm
0
comments
Labels: sharepoint, wss, zip
Thursday, June 05, 2008
WSS 3.0 Search Service on SBS
You need to install and start Windows Indexing service, start SharePoint Search Service, and Change the Identity of the SP website in IIS-->Application Pools-->Properties from Network User to Local System User
Posted by
SF
at
12:48 pm
0
comments
Labels: sbs, search service, small business server, wss
Monday, May 26, 2008
project management - agile
project management - agile
In order to be agile everyone in the team must be proficient.
Posted by
SF
at
11:21 am
0
comments
Thursday, May 22, 2008
ASP.NET DataBinding Eval V.S. Bind
Eval is used for one way data presentation whereas Bind is used to push data back to the database. Some detailed explanation:
http://www.15seconds.com/issue/040630.htm
Posted by
SF
at
3:26 pm
0
comments
Wednesday, May 14, 2008
Agile Project Management with Scrum
found this about Scrum, very helpful
http://agilescrum.tar.hu/agile_scrum_0035.html
Posted by
SF
at
3:54 pm
0
comments
Monday, May 12, 2008
"check-in pending" problem opening enterprise project within MS Project 2007
work around:
1. delete cache OR
2. when close the project, don't just click on "x", instead go File - Close
Posted by
SF
at
8:28 am
0
comments
Friday, May 09, 2008
Available fields in Microsoft Office Project 2007
Available fields in Microsoft Office Project 2007
http://office.microsoft.com/en-us/project/HA102369301033.aspx?pid=CH100788901033
Posted by
SF
at
8:49 am
0
comments
Thursday, May 08, 2008
what is Queue in MSPS 2007
Microsoft Office Project Server 2007 Queuing System
http://technet.microsoft.com/en-us/library/cc197395.aspx
Posted by
SF
at
4:32 pm
0
comments
Wednesday, May 07, 2008
what is resource units in Microsoft Office Project 2007
Sometimes it takes one resource to complete a task, but other times you need more. Sometimes a resource can only work part time. To account for these differences, Microsoft Office Project 2007 uses units (units: The quantity of a resource assigned to a task. The maximum units is the maximum number of units available for the resource. For example, if you have three plumbers, the maximum units is 300 percent or three plumbers working full-time.) to calculate the exact amount of time resources can work on a task............
Details: http://office.microsoft.com/en-us/project/HA102548291033.aspx
Posted by
SF
at
12:27 pm
0
comments
Configuring Linked Servers SQL Server 7 and 2000
found this post very helpful
http://www.informit.com/articles/article.aspx?p=21644
Posted by
SF
at
10:20 am
0
comments
Tuesday, May 06, 2008
Endnote x1 with WORD 2007 slows down Windows Vista x64
found a workaround for this issue
http://www.endnote.com/envista.asp
Posted by
SF
at
8:49 pm
0
comments
Tuesday, April 22, 2008
Walkthrough: Validating User Input in a Web Forms Page
found this article on MSDN very helpful
http://msdn2.microsoft.com/en-us/library/a0z2h4sw(VS.80).aspx
Visual Studio 2005, c#, web form, validator control
Posted by
SF
at
1:35 pm
0
comments
Wednesday, April 16, 2008
translate 'In' operator in SQL to LINQ
Just found out there is no 'In' in LINQ, instead there is an ANY in LINQ:
e.g.
var abc=
from d in mydb.department
where mydb.employee.Any(e => e.ProductID == d.ManagerId)
select d;
Posted by
SF
at
11:29 am
0
comments
Tuesday, April 15, 2008
OUTKAST - PROTOTYPE
[Intro]
I hope that you're the one
If not, you are the prototype
We'll tiptoe to the sun
And do thangs I know you like
[Hook]
I think I'm in love again [repeat]
[Verse 1]
Today must be my lucky day
Baby, you are the prototype
Do sumn' outta the ordinary
Like catch a manitee
Baby you are the prototype
I think I'm..
[Hook]
[Verse 2]
If we happen to part
Lord knows I don't want that
But hey, we can't be mad at God
We met today for a reason
I think I'm on the right track now
[Hook]
The Scene
Come here
[Hook]
[Outro (ad libs)]
Girl, right now I wanna say, I wanna say
I wanna say stank you very much
For picking me up
And bringing me back to this world
I can't, I'm not
I can't afford to not record
I thank I wanna say
I thank I wanna say stank you, stank you
Smelly much!
For picking me up and bringing me back to this world
Hey, hey John! Are we recording our ad libs?
Really?? Were we recording just then?
Let me hear that, that first one
When I first started
Posted by
SF
at
4:57 pm
0
comments
Tuesday, April 01, 2008
不归路
歌曲:不归路
歌手:迪克牛仔
专辑:忘记我还是忘记他
词∶许常德 曲∶林进璋
我没有退路
尽管你也千辛万苦
不愿认输
是良心让爱坚固
剩下由老天做主
爱你是一条不归路
一度我非常孤独
但是我更怕漂浮
不知道身在何处
有时候绝路也是人生一条路
爱让人全意付出忘记有结束
一心只想你幸福
疏忽了自己痛苦
我没有退路
尽管你也千辛万苦
不愿认输
是良心让爱坚固
剩下由老天做主
有時候错误也是人生一条路
谁不是跌到谷底才有点觉悟
只要你不想退出
我不怕命运残酷
我没有退路
尽管你也千辛万苦
不愿认输
是良心让爱坚固
剩下由老天做主
我没有退路
尽管我也千辛万苦也不愿认输
是良心让爱坚固
老天做主
Posted by
SF
at
8:51 am
0
comments
Monday, March 17, 2008
美丽的神话-成龙,金喜善
解开我 最神秘的等待 星星坠落 风在吹动
终于再将你拥入怀中 两颗心颤抖
相信我 不变的真心 千年等待 有我承诺
无论经过多少的寒冬 我绝不放手
이젠 나의 손을 잡고 눈을 감아요 yi jie na ye so nul qia go,nu nul ka ma yo.
(现在紧抓住我的手闭上眼睛)
우리 사랑했던 날들 생각해봐요 u li sa la hei dang nal dul,sei ga ke ba yo.
(请你回想起过去我们恋爱的日子)
우리 너무 사랑해서 아팠었네요 u li no mu sa la hei so,ha pa so ne yo.
(我们是因为太爱所以更使得我们痛苦)
서로 사랑한단 말도 못했었네요 so lo sa la ha dan mal do,mo tei so ne yo.
(我们连"爱你"这句话都无法讲)
每一夜 被心痛穿越 思念永没有终点
早习惯了孤独相随 我微笑面对
相信我 已选择等待 再多苦痛也不闪躲
只有你的温柔能解救 无边的冷漠
이젠 나의 손을 잡고 눈을 감아요 yi jie na ye so nul qia go,nu nul ka ma yo.
(现在紧抓住我的手闭上眼睛)
우리 사랑했던 날들 생각해봐요 u li sa la hei dang nal dul,sei ga ke ba yo.
(请你回想起过去我们恋爱的日子)
우리 너무 사랑해서 아팠었네요 u li no mu sa la hei so,ha pa so ne yo.
(我们是因为太爱所以更使得我们痛苦)
서로 사랑한단 말도 못했었네요 so lo sa la ha dan mal do,mo tei so ne yo.
(我们连"爱你"这句话都无法讲)
让爱成为你我心中 那永远盛开的花
穿越时空绝不低头 永不放弃的梦
우리 너무 사랑해서 아팠었네요 u li no mu sa la hei so,ha pa so ne yo.
(我们是因为太爱所以更使得我们痛苦)
서로 사랑한단 말도 못했었네요 so lo sa la ha dan mal do,mo tei so ne yo.
(我们连"爱你"这句话都无法讲)
让爱成为你我心中 那永远盛开的花
우리 소중했던 약속 잊지는 말아요 u li so ju hei dang ya kso,yi ji ni ma la yo.
(我们千万不要忘记我们的约定)
唯有真爱追随你我 穿越无尽时空
서로 사랑한단 말도 못했었네요 so lo sa la ha dan mal do,mo tei so ne yo.
(我们连"爱你"这句话都无法讲)
爱是心中唯一不变美丽的神话
Posted by
SF
at
8:33 am
0
comments
美丽的神话-孙楠,韩虹
梦中的人熟悉的脸孔
你是我守候的温柔
就算泪水淹没天地
我不会放手,每一刻孤独的承受
只因我曾许下承诺
你我之间熟悉的感动
爱就要苏醒
万世沧桑唯有爱是永远的神话
潮起潮落始终不悔真爱的相约
几番若痛的纠缠多少黑夜掐扎
紧握双手让我和你再也不离分
枕上雪冰封的爱恋
真心相摇篮才能融解
风中摇曳炉上的火
不灭亦不休
等待花开春去春又来
无情岁月笑我痴狂
心如钢铁任世界荒芜
思念永相随
悲欢负月唯有爱是永远的神话
谁都没有遗忘古老,古老的誓言
你的泪水化为漫天飞舞的彩蝶
爱是翼下之风两心相随自在飞
你就是我心中唯一美丽的神话
Posted by
SF
at
8:32 am
0
comments
爱情诺曼底
六月六日六时六分刚过六十秒
脆弱的堡垒远眺如风化的沙雕
轻抚着断裂的皱纹沧桑一条条
谁的心早已死掉
曾和你相爱如天命难违的凑巧
为何与你对决变成轮回的纷扰
爱如那常消的海潮退去时飘渺
我的心不再计较
情爱它似毒药 你我早就应该知道
为何却不停的要
为何却一再的要
我怎么才能登上你的爱情诺曼底
别让天与海的距离 衡量爱与恨的对立
怎么才能让我登上你的爱情诺曼底
狂奔在破晓的大地 拼了命也要找到你
占领这爱情诺曼底 Yeah
Posted by
SF
at
8:30 am
0
comments
Thursday, March 13, 2008
挑衅
我的梦早已归零 我的爱结成冰
退色的刺青 残留的姓名 那是我的曾经
别为我动了真情 别怪我那么ㄍㄧㄥ
孤独的背影 落寞的神情 经不起你的挑衅
不要闯进我冰冷的爱情 我怕沉睡的梦被你惊醒
无论束手就擒 或是抵挡你的入侵 都会让我 摇摆不定 触景伤情
你的梦如此清醒 你的爱太冷静
催泪的叮咛 温柔的神情 却又让我动心
别让我掉入陷阱 别恨我不敢听
固执的个性 坚定的表情 经不起你的挑衅
不要闯进我冰冷的爱情 我怕沉睡的梦被你惊醒
无论束手就擒 或是抵挡你的入侵 对我来说 都是挑衅
不要挑衅我冰冷的爱情 我怕醒来会爱你爱不停
请你别再靠近 不要让我恨不下心
现在的我 经不起你 一再挑衅
Posted by
SF
at
2:46 pm
0
comments
Friday, February 29, 2008
check all or none items in checkedlistbox
if (clientList.CheckedItems.Count == 0)
for (int i = 0; i < clientList.Items.Count; i++)
{
clientList.SetItemChecked(i, true);
}
else
for (int i = 0; i < clientList.Items.Count; i++)
{
clientList.SetItemChecked(i, false);
}
Posted by
SF
at
2:38 pm
0
comments
Visual Studio 2008 checkedlistbox
figured this way to databind checkedlistbox, not sure why DataSourse, ValueMember, and DisplayMember do not appear in intellisense
this.clientsTableAdapter.Fill(this.dataSet1.Clients);
practice2.DataSet1.ClientsDataTable t = clientsTableAdapter.GetData();
checkedListBox1.DataSource = t;
checkedListBox1.ValueMember = t.IdColumn.ColumnName;
checkedListBox1.DisplayMember = t.NameColumn.ColumnName;
Posted by
SF
at
12:18 pm
0
comments
Monday, February 25, 2008
detect if ActiveX is disabled
found this two links quite useful
tect the browser using ASP.NET and C#
http://www.codeproject.com/KB/aspnet/detectbrowser.aspx
How Can I Tell if ActiveX is Enabled in Internet Explorer?
http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov05/hey1114.mspx
Posted by
SF
at
3:15 pm
0
comments
Thursday, February 14, 2008
Wednesday, February 06, 2008
HAPPY CHINESE NEW YEAR TO YOU ALL!!!!!!
五谷丰登 六畜兴旺 吉庆有余
惠风和畅 发家致富 日度小康
鼠年大吉 万事遂心 利国利民
一往无前 四海皆春 普天同庆
人逢盛世情无限;鼠拱华门岁有余
吉日生财鼠拱户;新春纳福鹊登梅
名题雁塔登金榜;鼠拱华门报吉祥
戌年引导小康路;亥岁迎来锦绣春
孟春之月方营室;宝盖进豕恰是家
国泰民安戌岁乐;粮丰财茂亥春兴
金榜题名光耀第;喜鼠拱户院生财
猪守家门旧主喜;鼠增财富新春欢
猪岁已赢十段锦;鼠年更上一层楼
猪年已展千重锦;鼠岁再登百步楼
猪问平安随腊去;鼠生财富报春来
Posted by
SF
at
9:09 am
0
comments
Thursday, November 29, 2007
make google dance~
found this link somewhere, it provides a block of javascript that makes images in google image search result dance in a queue, lol funny
http://www3.webng.com/redtophank/cit.html
Posted by
SF
at
9:41 am
0
comments
Monday, October 29, 2007
ORA-00979: not a GROUP BY expression
problem query
select class_schedule.class_id, class_schedule.sum(class_schedule.enrolments) tot_enr, class.name from class_schedule inner join class on class_schedule.class_id = class.id group by class_schedule.class.id
solution
select class_schedule.class_id,
sum(class_schedule.enrolments) tot_enr, class.name
from class_schedule
inner join
class on class_schedule.class_id = class.id
group by class_schedule.class_id, class.name
Posted by
SF
at
11:01 pm
0
comments
Sunday, October 21, 2007
how to convert my query to stored procedure
I have this procedure below:
set serveroutput on
DECLARE
v_counter NUMBER(7) := 0;
v_tax NUMBER(11,2) := 0;
v_an_sal NUMBER(11,2) := 0;
CURSOR emp_cursor IS
SELECT id, last_name, first_name, salary
FROM scott.s_emp;
--r_emp scott.s_emp%ROWTYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE(rpad(‘ID’,5) || rpad(‘LAST_NAME’, 15) || rpad(‘FIRST_NAME’,15) || lpad(‘ANNUAL_SALARY’,11) || lpad(‘TAX’,11));
DBMS_OUTPUT.PUT_LINE(rpad(‘____ ’,5) || rpad(‘_______________’, 15) || rpad(‘_______________’,15) || lpad(‘___________’,11) || lpad(‘___________’,11));
FOR r_emp IN emp_cursor LOOP
v_counter := v_counter + 1;
v_tax := 0;
v_an_sal := r_emp.salary * 12;
IF v_an_sal > 150000 THEN
v_tax := 47850 + (v_an_sal -150000)*0.45;
ELSIF v_an_sal > 75000 THEN
v_tax := 17850 + (v_an_sal -75000)*0.40;
ELSIF v_an_sal > 25000 THEN
v_tax := 2850 + (v_an_sal -25000)*0.30;
ELSIF v_an_sal > 6000 THEN
v_tax := (v_an_sal -6000)*0.15;
ELSE
v_tax := 0;
END IF;
DBMS_OUTPUT.PUT_LINE(rpad(r_emp.id,5) || rpad(r_emp.last_name, 15) || rpad(r_emp.first_name,15) || lpad(v_an_sal,11) || lpad(v_tax,11));
IF v_counter mod 5 = 0 THEN
DBMS_OUTPUT.PUT_LINE('******************************************************');
END IF;
END LOOP;
END;
/
I need to convert it to a stored procedure (or create a sored procedure for this) so that i can call it from my psp pages.
solution:
remove 'DECLARE set serveroutput on'
replace with 'CREATE OR REPLACE PROCEDURE proc_emp_sum_analysis AS'
Posted by
SF
at
5:04 pm
0
comments
loop through query result and print each row in stored procedure
have this query which returns a set of rows, How can I loop through each row and display them using dbms.output.put_line? Please notice in the where clause there is a variable 'v_trainer_id', the variable value is known (retrieved from a column of a current row of another cursor)
select customer.id as customer_id, membership.join_date, membership.join_fee,round(months_between(sysdate, membership.join_date),0) as months_joined, membership_plan.monthly_price, membership.monthly_discount, (membership_plan.monthly_price- membership.monthly_discount) * round(months_between(sysdate, membership.join_date),0) as total_paidfrom membership,membership_plan,customerwhere membership.membership_plan_id = membership_plan.id andcustomer.id=membership.customer_id andmembership.trainer_id = v_trainer_idorder bycustomer.id;
solution:
v_cur_tid := r_trainer.trainer_id;FOR r_mem IN(select membership.customer_id as cust_id, membership.join_date, membership.join_fee,round(months_between(sysdate, membership.join_date),0) as months_joined, membership_plan.monthly_price, membership.monthly_discount, (membership_plan.monthly_price- membership.monthly_discount) * round(months_between(sysdate, membership.join_date),0) as total_paidfrom membership,membership_planwhere membership.membership_plan_id = membership_plan.id andmembership.trainer_id = v_cur_tidorder bymembership.customer_id)LOOP
Posted by
SF
at
2:01 am
0
comments
PL/SQL: ORA-01744: inappropriate INTO
I have this part of the stored procedure, trying to use one select query to fill in 2 variables, got error 'PL/SQL: ORA-01744: inappropriate INTO'
--print summary of subsection
select t.* from (select count(membership.id) into v_tot_mem_by_trainer,sum((membership_plan.monthly_price- membership.monthly_discount) * round(months_between(sysdate, membership.join_date),0)) into v_tot_rev_by_trainerfrom membership, membership_planwhere membership.trainer_id = r_trainer.trainer_id andmembership.membership_plan_id = membership_plan.id) t;
this is the original select query that has no problem
select t.* from (select count(membership.id) as total_number_of_members,sum((membership_plan.monthly_price- membership.monthly_discount) * round(months_between(sysdate, membership.join_date),0)) as total_membership_paymentfrom membership, membership_planwhere membership.membership_plan_id = membership_plan.id) t;
the solution:
select t.* into v_tot_mem_by_trainer, v_tot_rev_by_trainer from (select count(membership.id),sum((membership_plan.monthly_price- membership.monthly_discount) * round(months_between(sysdate, membership.join_date),0))from membership, membership_planwhere membership.trainer_id = r_trainer.trainer_id andmembership.membership_plan_id = membership_plan.id) t;
Posted by
SF
at
12:47 am
0
comments
Saturday, October 20, 2007
ORA-00937: not a single-group group function
I want to select some data from table membership and membership_plan, these 2 have some relationships with each other. In the same query, I also want to 'select count(*) from customers' where customers table has no relationship with the other 2 tables, I just want to find out the total number of customers and display with the rest of the query results.
select (select count(id) from customer), count(membership.id) as total_number_of_members, sum((membership_plan.monthly_price- membership.monthly_discount) * round(months_between(sysdate, membership.join_date),0)) as total_all_members from membership,membership_planwhere membership.membership_plan_id = membership_plan.id;
I got an error message as below:
ERROR at line 1:ORA-00937: not a single-group group function
solution:
select (select count(id) from customer), t.* from (select count(membership.id) as total_number_of_members,
sum((membership_plan.monthly_price- membership.monthly_discount) * round(months_between(sysdate, membership.join_date),0)) as total_all_members
from membership, membership_plan
where membership.membership_plan_id = membership_plan.id) t;
Posted by
SF
at
12:01 am
0
comments
Tuesday, October 16, 2007
oracle sqlldr datetime value problem
this is my loader ctl file
LOAD DATAINFILE 'trainer.data' BADFILE 'trainer.bad'DISCARDFILE 'trainer.dsc'REPLACEINTO TABLE trainerFIELDS TERMINATED BY ','TRAILING NULLCOLS(ID TERMINATED BY ',' ENCLOSED BY '"',FN TERMINATED BY ',' ENCLOSED BY '"',LN TERMINATED BY ',' ENCLOSED BY '"',GENDER TERMINATED BY ',' ENCLOSED BY '"',PHONE TERMINATED BY ',' ENCLOSED BY '"',MOBILE TERMINATED BY ',' ENCLOSED BY '"',EMAIL TERMINATED BY ',' ENCLOSED BY '"',CERTIFICATE_LEVEL TERMINATED BY ',' ENCLOSED BY '"',IS_PERSONAL_TRAINER TERMINATED BY ',' ENCLOSED BY '"',HIRE_DATE TERMINATED BY ',' ENCLOSED BY '"',IS_ACTIVE ENCLOSED BY '"')
the field 'hire_date' is a datetime field. e.g. '15-JUN-2005 13:30' in the format of 'DD-MON-YYYY HH24:Mi'. please see the first 3 rows of my datafile below:
"1","Cara","Surename","m","06623355","0446002359","lorem.ut.aliquam@dictum.edu","a","y","06-JUN-2006 00:00","y""2","Noble","Surename","m","28435168","0451498500","Mauris.magna.Duis@id.com","a","n","06-JUN-2006 00:00","y""3","Coby","Surename","f","79907443","0460112510","Mauris@accumsan.ca","d","n","06-JUN-2006 00:00","y"
then when i executed the ctl file, i got this error below in the log file
Record 1: Rejected - Error on table TRAINER, column HIRE_DATE.ORA-01830: date format picture ends before converting entire input stringRecord 2: Rejected - Error on table TRAINER, column HIRE_DATE.ORA-01830: date format picture ends before converting entire input stringRecord 3: Rejected - Error on table TRAINER, column HIRE_DATE.ORA-01830: date format picture ends before converting entire input string
solution:
HIRE_DATE DATE "DD-MON-YYYY HH24:Mi" TERMINATED BY ',' ENCLOSED BY '"',
Posted by
SF
at
2:03 am
0
comments
Monday, October 15, 2007
An old joke about project manager
A tourist walked into a pet shop and was looking at the animals on display. While he was there,another customer walked in and said to the shopkeeper, "I'll have a C monkey please." Theshopkeeper nodded, went over to a cage at the side of the shop and took out a monkey. Hefitted a collar and leash, handed it to the customer, saying, "That'll be £5,000."
The customer paid and walked out with his monkey.
Startled, the tourist went over to the shopkeeper and said, "That was a very expensive monkey. Most of them are only a few hundred pounds. Why did it cost so much?" The shopkeeperanswered, "Ah, that monkey can program in C - very fast, tight code, no bugs, well worth themoney."
The tourist looked at a monkey in another cage. "Hey, that one's even more expensive! £10,000! What does it do?"
"Oh, that one's a C++ monkey; it can manage object-oriented programming, Visual C++, even some Java. All the really useful stuff," said the shopkeeper.
The tourist looked around for a little longer and saw a third monkey in a cage of its own. The price tag around its neck read £50,000. The tourist gasped to the shopkeeper, "That one costs more than all the others put together! What on earth does it do?"
The shopkeeper replied, "Well, I haven't actually seen it do anything, but it says it's a project manager".
Posted by
SF
at
10:19 am
0
comments
Sunday, October 14, 2007
oracle how to random select a value out of 2 letters
select chr(121 - 11 * (round(dbms_random.value))) is_successful from dual
or
select case when dbms_random.value(0,1) < 0.5 then 'y' else 'n' end is_successful from dual
or
select translate(dbms_random.string('U',1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','ynynynynynynynynynynynynyn') from dual
or
select distinct First_Value(is_successful) over(order by dbms_random.value) as is_successfulfrom (select 'n' as is_successful from dual union all select 'y' from dual);
or
substr('yn', dbms_random.value(1,3), 1)
Posted by
SF
at
12:30 pm
0
comments
Friday, October 12, 2007
Thursday, October 11, 2007
oracle get a rendom set of string value with length in between 0 and 100
select dbms_random.string('l',dbms_random.value(0,100)) from dual
Posted by
SF
at
8:34 pm
0
comments
oracle return a range of integer
select level num from dual connect by level <= 5;
NUM
1
2
3
4
5
Posted by
SF
at
7:27 pm
0
comments
oracle get a random value out of a query result
I have a query:
select id from class_schedule where id not in (select distinct(event_id) from trainer_schedule)
I want to pick up a random value from this query result and assign it to a varible e.g. randomID.
solution:
randomID :=
select id from
(
select id from class_schedule
where id not in (select distinct(event_id) from trainer_schedule)
order by dbms_random.value
)
where rownum = 1
Posted by
SF
at
12:20 am
0
comments
Wednesday, October 10, 2007
oracle update one table with values from another table
e.g.
update membership
set membership.join_fee = (select membership_plan.join_fee
from membership_plan
where membership.membership_plan_id = membership_plan.id)
where exists (select 1
from membership_plan
where membership.membership_plan_id = membership_plan.id)
Posted by
SF
at
2:15 am
0
comments
ORA-06550 problem in script
Tried to execute the script below got error The query:
DECLARE
CURSOR sol_cursor IS select * from membership;
months NUMBER(5,0) :=0;
BEGIN
FOR r_sol IN sol_cursor LOOP
months := (select min_months from membership_plan where id = r_sol.membership_plan_id);
UPDATE membership
SET end_date = add_months(r_sol.end_date,months)
WHERE id = r_sol.id
END LOOP;
END;
ERROR:
ORA-06550: line 6, column 12: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null othersavg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe
SOLUTION:
changing:
months := (select min_months from membership_plan where id = r_sol.membership_plan_id);
to:
select min_months INTO months from membership_plan where id = r_sol.membership_plan_id;
Posted by
SF
at
2:11 am
0
comments
Tuesday, October 09, 2007
oracle add an hour
select to_char(to_date('15-08-2006 21:30','DD-MM-YYYY HH24:Mi')+1/24,'DD-MM-YYYY HH24:Mi') from dual
or
select sysdate, sysdate + 5/24 from dual;
Posted by
SF
at
2:07 am
0
comments
I created this, do you know what it does?
update class_schedule set start_time= add_months(start_time, -12*
(select to_number(to_char(start_time,'yyyy')-2006) from dual)) where
to_char(start_time,'yyyy')> to_char(2006)
GOOD LUCK!
Posted by
SF
at
2:02 am
0
comments
oracle add a year
update class_schedule set start_time = (select add_months(start_time,12*2003)from dual)
or
add_months(trunc(start_time),12*35)
Posted by
SF
at
1:16 am
0
comments
oracle update and display datetime in Date datatype fields
update class_schedule set start_time = to_date('2003-06-13 15:18','YYYY-MM-DD HH24:MI') where id=17
select to_char(start_time,'YYYY-MM-DD HH24:MI') from class_schedule where id=17;
Posted by
SF
at
12:08 am
0
comments
Monday, October 08, 2007
oracle generate a random date using julian dates
SELECT TO_CHAR(TO_DATE('2006-06-06', 'YYYY-MM-DD'), 'J') FROM DUAL;
--> 2453893
SELECT TO_CHAR(TO_DATE('2007-10-01', 'YYYY-MM-DD'), 'J') FROM DUAL;
--> 2454375
SELECT TO_DATE(TRUNC(DBMS_RANDOM.VALUE(2453893, 2454375)), 'J') FROM DUAL;
--> 19/SEP/06
Posted by
SF
at
7:40 pm
0
comments
Sunday, October 07, 2007
using pl/sql dbms_random function for generating random values
UPDATE purchase_order_line
SET discount_total = (select round(dbms_random.value(0, 9999.22),2) from dual)
WHERE purchase_order_id = r_po.purchase_order_id;
Posted by
SF
at
3:43 am
0
comments
Wednesday, September 26, 2007
using general expression when creating check constraint in pl/sql
CONSTRAINT "CUSTOMER_CK_PHONE" CHECK (REGEXP_LIKE ( phone, '^([0-9]*?\ ?\/?[0-9]{4}[0-9]{4})$ ' ) ) ENABLE
Posted by
SF
at
10:09 pm
0
comments
Monday, September 24, 2007
Oracle Database 10g Express Edition forgot password after installation
symptom:
I installed 10g ex a while ago, now try to login, but forgot what the password was for the default username "system", can any one please help to retrieve the password?
fix:
SQL> conn / as sysdba
Connected.
SQL> alter user system identified by
Posted by
SF
at
11:28 pm
0
comments
Sunday, September 23, 2007
PL/SQL DBMS_OUTPUT.PUT_LINE formating experience
for the header row, do this:
DBMS_OUTPUT.PUT_LINE(rpad(‘ID’,5) || rpad(‘LAST_NAME’, 15) || rpad(‘FIRST_NAME’,15) || lpad(‘ANNUAL_SALARY’,11) || lpad(‘TAX’,11) || lpad(‘COMMISSION_PCT’, 16));
DBMS_OUTPUT.PUT_LINE(rpad(‘____ ’,5) || rpad(‘_______________’, 15) || rpad(‘_______________’,15) || lpad(‘___________’,11) || lpad(‘___________’,11) || lpad(‘______________’, 16));
then in the loop I did:
DBMS_OUTPUT.PUT_LINE(rpad(r_emp.id,5) || rpad(r_emp.last_name, 15) || rpad(r_emp.first_name,15) || lpad(v_an_sal,11) || lpad(v_tax,11) || lpad(v_com_pct, 16));
not very enjoyable way of formating, but it worked......
Posted by
SF
at
9:10 pm
0
comments
Sunday, September 09, 2007
sqlplus view existing indexes
select * from user_indexes
where table_owner like 'xxxxxx' and table_name like 'ABC';
Posted by
SF
at
8:29 pm
0
comments
Friday, September 07, 2007
Wednesday, August 29, 2007
upload sql database to the host environment
found this tool that makes it easier to upload sql database to the host environment
http://www.codeplex.com/sqlhost
Posted by
SF
at
4:58 pm
0
comments
Friday, August 24, 2007
oracle sqlplus
select TABLE_NAME, CONSTRAINT_NAME, STATUS
from USER_CONSTRAINTS
where TABLE_NAME like 'INVOICE';
the word after 'like' must be in capital, otherwise you won't get any result
Posted by
SF
at
10:39 pm
0
comments
make your DNN site home page style different to other pages
create a homepage skin with the LogoPane instead of the Logo skin token
all other pages will use a skin that has standard Logo skin token
Posted by
SF
at
10:19 pm
0
comments
yellow color flash when open a new page on DNN site
the background color of my site is mainly dark-red and black, the text is in white color. When i click on a link to open another page, the background always flash in yellow color and return back to normal. what happened?
answer:
there is a background color set to be yellow in the css, check it
Posted by
SF
at
10:16 pm
0
comments
how to remove DNN version number on the tab
update DNN site from version 3.1 to 3.3.7, now when i open the site in IE7, the version number is displayed together with the page title on the IE7 tab:
My Site > Home (DNN 3.3.7)
in order to get rid of the stuff in '()', Log in as superuser ("host"), go to host settings in host menu and uncheck "show copyright credits".
Posted by
SF
at
10:14 pm
0
comments
Thursday, August 09, 2007
Oracle DB 10g EX SQL - case sensitivity
Only the text with quotes is case sensitive.
Posted by
SF
at
10:10 am
0
comments
Wednesday, August 08, 2007
Oracle DB 10g EX SQL - create table - syntax to add Check
CREATE TABLE student(
student_no NUMBER(3) NOT NULL,
age NUMBER(2) CHECK(age>18),
gender CHAR(1) CHECK(gender='m' or gender='f') NOT NULL
);
Posted by
SF
at
10:26 am
0
comments
Tuesday, August 07, 2007
Oracle DB 10g EX SQL - query the list of all columns in curent table
SELECT * FROM tab;
Posted by
SF
at
2:42 pm
0
comments
MS SQL - query the list of all columns in curent table
select column_name from information_schema.columns where table_name ='authors'
Posted by
SF
at
2:42 pm
0
comments
MS SQL - query the list of all tables in curent schema
select * from sysobjects where type = 'U' and uid=user_id('dbo')
Posted by
SF
at
2:22 pm
0
comments
Sunday, August 05, 2007
Oracle DB 10g EX SQL - query the list of all tables in curent schema
SELECT * FROM tab;
Posted by
SF
at
11:39 pm
0
comments
Thursday, May 10, 2007
filter a GridView column based on another column, ASP.NET
< asp:Button runat="server" ID="GoButton" Text="Go" CommandName="Select" Visible='<%# ((System.Data.DataRowView)Container.DataItem)["ABC"] != DBNull.Value %/>' />
Posted by
SF
at
9:59 am
0
comments
Wednesday, May 09, 2007
Only String Type accpts null value in mssql db
if you want to do assign a NULL value to a integer type column, u will get error, I had to try to give a -1 value to work around, is there a better/real solution?
Posted by
SF
at
3:42 pm
0
comments
Thursday, April 12, 2007
VS2005 ASP.NET Gridview Date Format
tried to format date boundfield to {0:dd/MM/YYYY}, it won't work, in order to solve the problem, you need to set the "HtmlEncode" of the column to "false"
Posted by
SF
at
3:54 pm
0
comments