CodeCharge Studio | All ASP PHP Perl ColdFusion Java C#.NET VB.NET |
This example shows how to read a single value from a database. In this case, we have a Header page which contains a UserName Label that is used to display the user's name.
Use the DLookup action.
Function Header_BeforeShow(Sender) Header.UserName.Value = CCDLookUp("user_name","users","user_id=" & DBConnection1.ToSQL(CCGetUserID(),ccsInteger), DBConnection1) End Function
function Header_BeforeShow(& $sender) { global $Header; global $DBConnection1; $Header->UserName->SetValue(CCDLookUp("user_name","users","user_id=". $DBConnection1->ToSQL(CCGetUserID(), ccsInteger), $DBConnection1) ); }
sub Header_BeforeShow() { $DBConnection1 = clsDBConnection1->new(); $result = CCDLookUp("first_name", "users", "user_id=". $DBConnection1->ToSQL(CCGetUserID(), $ccsInteger), $DBConnection1); $Header->{UserName}->SetValue($result); }
<!--Header_BeforeShow ---> <CFModule Template="CCDLookUp.cfm" table="Users" field="first_name" where="User_ID=1" Connection="Connection1"> <CFSET fldUserName=CCDLookup>
'Header_BeforeShow UserName.Text = (New TextField("",Settings.Connection1DataAccessObject.ExecuteScalar("SELECT user_name FROM users WHERE user_id="&DBUtility.UserId))).GetFormattedValue("")
//Header_BeforeShow UserName.Text = (new TextField("",Settings.Connection1DataAccessObject.ExecuteScalar("SELECT user_name FROM users WHERE user_id=" + DBUtility.UserId))).GetFormattedValue("");
//Header_BeforeShow e.getPage().getControl("UserName").setValue( DBTools.dLookUp("User_Name","Users","User_ID="+Utils.getUserId(e.getPage()),"Connection1"));