I have found it handy to drag the split bar down to get two panes of the same file.
Brook's Software Development Blog
Monday, January 20, 2020
Viewing Different Locations in the Same Visual Studio File
I frequently want to view two parts of a file at the same time. Like if I am copying or moving code from one place to another in the same file.
I have found it handy to drag the split bar down to get two panes of the same file.
Sometimes I want to view more than two places in a file at once or the two blocks of code I am looking at are really long, so I would like to see them side by side. For that, I select from the menu Window => New Window.
I have found it handy to drag the split bar down to get two panes of the same file.
Wednesday, September 26, 2018
CallerMemberName (C# 5.0 and above)
CallerMemberName (C# 5.0 and above)
propertyName));
}
When the CallerMemberName attribute is applied to an argument, the calling method/property/etc name will be supplied. This is useful for snippets, and for implementing non-volatile sections of code without needing to fill-in specifics.
Example:
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([ CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(Thursday, April 14, 2016
Error When Using Distinct - ORA-01791: not a SELECTed expression
The Problem
I had a query that was working, but when I added a DISTINCT to it started throwing an error. The error I was receiving was ORA-01791: not a SELECTed expression. It didn't give me which field it didn't like, so I was confused.
The Solution
What I found was that once DISTINCT was in play all the fields in my ORDER BY had to be in the SELECT. All of the ORDER BY fields had to be fields and not calculations.
I had a query that was working, but when I added a DISTINCT to it started throwing an error. The error I was receiving was ORA-01791: not a SELECTed expression. It didn't give me which field it didn't like, so I was confused.
The Solution
What I found was that once DISTINCT was in play all the fields in my ORDER BY had to be in the SELECT. All of the ORDER BY fields had to be fields and not calculations.
Friday, March 18, 2016
How to insert an ampersand into an Oracle field
I was trying to insert a value into a varchar2 field. The value contained an ampersand. Something like "A&B Home Remodeling". It kept giving me an error like &B was a variable.
What worked for me was storing it like this:
'A'||'&'||'B'
It like that much better. I also saw suggestions to chr(38). I did not try that, so I am not sure if it works, but I am guessing it would be very similar to what I did. Something like:
'A'||chr(38)||'B'
Wednesday, December 16, 2015
Updating a Session Variable With JavaScript
Although JavaScript is client side code with an AJAX call you can set or update a session variable on the server when client side code fires.
In my case I couldn't do a post back, since I could not have a form on the page, so I needed to do a reload. I still needed the values from the page, which reload does not preserve. Because it is a reload it shouldn't preserve those values, but for my purpose I needed one of them.
What I ended up doing was using JQuery to make an AJAX call to a handler page.
Once the AJAX call returns then I call the reload. The code looks similar to this:
$.ajax(
{
cache: false,
url: sURL,
datatype: "html"
}).done(function (data) {
if (data != "") alert(data);
//alert("Should reload");
window.location.href = window.location;
window.location.reload(true);
})
.fail(function (xhr, ajaxOptions, thrownError) {
alert("fail");
alert(thrownError);
});
sURL is the address of the handler page. You will need to pass a parameter to the handler page to tell it that you want to call the routine in the handler that sets the session variable. The handler code in ASP.NET with C# would look like this:
static HttpContext _context;
public void ProcessRequest(HttpContext context)
{
string retval = "";
_context = context;
switch (context.Request["method"])
{
case "SetSession":
Session[context.Request["SessionVarName"])] = context.Request["SessionValue"])
break;
default:
context.Response.ContentType = "text/plain";
retval = "Invalid method specified";
break;
}
context.Response.Write(retval);
}
In my case I couldn't do a post back, since I could not have a form on the page, so I needed to do a reload. I still needed the values from the page, which reload does not preserve. Because it is a reload it shouldn't preserve those values, but for my purpose I needed one of them.
What I ended up doing was using JQuery to make an AJAX call to a handler page.
Once the AJAX call returns then I call the reload. The code looks similar to this:
$.ajax(
{
cache: false,
url: sURL,
datatype: "html"
}).done(function (data) {
if (data != "") alert(data);
//alert("Should reload");
window.location.href = window.location;
window.location.reload(true);
})
.fail(function (xhr, ajaxOptions, thrownError) {
alert("fail");
alert(thrownError);
});
sURL is the address of the handler page. You will need to pass a parameter to the handler page to tell it that you want to call the routine in the handler that sets the session variable. The handler code in ASP.NET with C# would look like this:
static HttpContext _context;
public void ProcessRequest(HttpContext context)
{
string retval = "";
_context = context;
switch (context.Request["method"])
{
case "SetSession":
Session[context.Request["SessionVarName"])] = context.Request["SessionValue"])
break;
default:
context.Response.ContentType = "text/plain";
retval = "Invalid method specified";
break;
}
context.Response.Write(retval);
}
Tuesday, November 10, 2015
Oracle Scheduled Jobs
TO CREATE A JOB:
Begin
Dbms_scheduler.Create_job (
Job_name => 'RUN_JOB_TO_RUN',
Job_type => 'PLSQL_BLOCK',
Job_action => 'BEGIN JOB_TO_RUN(); END;',
Start_date => To_timestamp_tz('10-NOV-2015 13:00:00','DD-MM-YYYY HH24:MI:SS'),
Repeat_interval => 'FREQ = DAILY; BYHOUR=13',
comments => 'Some job to run.',
Enabled => True);
End;
TO UPDATE A JOB:
begin
Dbms_scheduler.Set_attribute
( name => 'RUN_JOB_TO_RUN'
, Attribute =>'REPEAT_INTERVAL'
, value =>'FREQ=DAILY; BYHOUR=2');
End;
Thursday, September 24, 2015
Format Strings to Use a Percent Sign (%) Without the Formatter Multiplying the Value by 100
I had an application that needed to display a value with a percent sign (%) after it. The value had already been converted from decimal to integer, or in other words had already been multiplied by 100. I did not have the option to just append a % at the end of the string. All the object gave me access to was the format. I tried "#0%", which gave me what I wanted, except that it multiplied the value by 100, so 20% became 2000%.
After a little research I found that using an escape character gave me what I wanted.
ToString("#0\\%")
After a little research I found that using an escape character gave me what I wanted.
ToString("#0\\%")
Subscribe to:
Posts (Atom)