Monday, 8 December 2014

PLS-00201: identifier "sp_name" must be declared

If you have created a stored procedure in oracle and are trying to use it in your .net code and you get the 

above error while running the sp , make sure the following

1. Create the SP using the admin account


2. Grant execute rights to the user that is running the SP

3. Check if you have a public synonym for the SP in question

4. If not then create the public synonym for the SP

CREATE PUBLIC SYNONYM SYNONYM_NAME FOR ADMIN.SP_NAME;

4. Also grant execute to the public synonym also
     GRANT EXECUTE ON "ADMINACCOUNT"."SP_NAME" TO "PUBLIC_SYNONYM";


5. If a public synonym is not created or you do not want to create a public synonym , then you can run the SP by appending the ADMIN schema to the SP
    ADMINACCOUNT.SP_NAME

Thursday, 24 October 2013

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'adGallery' - MVC 4

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'adGallery'

If you get this error then do not include the supporting jquery in the classic way like
-- @*<script type="text/javascript" src="~/Scripts/jquery-1.7.1.min.js"></script>

Instead add your jquery to the bundle . See this to find out how to add your adGallery jquery to bundle.
-- http://stackoverflow.com/questions/12192646/why-use-scripts-render-bundles-jquery

Wednesday, 23 October 2013

WebGoat.net set up

I was setting up WebGoat.net on my machine. Offcourse there is Dinis's good blog on this(http://blog.diniscruz.com/2013/06/webgoatnet-in-action-and-how-i-set-it-up.html). But still i ran into the following issues

1. After i downloaded the code i did not know what is sqlite3. I downloaded it from their site. I downloaded the code and the dll

2. I downloaded the code and rebuilt it using visual studio to get the sqlite3.exe

3. I placed the dll in bin and i placed the sqlite3.exe in ...\WebGoat.NET-master\WebGoat.NET-master\WebGoat\DB_Scripts

4. I ran into issues at this line of code in SqliteDbProvider.cs
SqliteConnection .CreateFile(_dbFileName);

It threw a permission error. That is becase the _dbFileName points to a folder and not a file.

5. What is expected here is the DB name. I gave the name as classicmodels.db

6. You need to specify the name in Default.config

7. I browsed to ...\WebGoat.NET-master\WebGoat.NET-master\WebGoat\DB_Scripts form the command prompt , here i created the DB with the following command
> sqlite3 classicmodels.db

8. Then i created the db with the following command
> .read create_webgoatcoins_sqlite3.sql
it did not work the first time, hence i executed it again as a true progammer and without knowing why
> .read create_webgoatcoins_sqlite3.sql

Bingo it created the db

9. Then i tried to load the data by running
> .read load_webgoatcoins_sqlite3.sql

it errored out . No matter how many times!

10. Then i went to the UI and clicked on Rebuild database and bingo i was on my Suzuki Samurai(the bike by work no problem)



 


Monday, 21 October 2013

Getting serious about social media

I don't think social media is a place to get serious about. Especially some of the casual social media like the Facebook, twitter etc. These places are there to have some fun and that is it. I don't think it is a place to have serious discussions about anything like politics, religion or anything else. Primarily because people get to the social media casually. They take social media casually. I see people expressing some strong views about religion, politics and some even bringing their personal lives on it. I think the latter one is ridiculous. Why would anybody want to bring their personal lives on the social media. I also see people putting all their day to day information on the social media. This is so dangerous in these days of identity theft etc. Believe me identity theft is the next big thing. Go read about it online.
If you do wish to express strong political, religious or social views, go to the respective forums. Get to the parliament if you are serious about politics. If you want to get serious about religion go to the mosques or other places where people are serious about it. Just imagine, you have a religious posting in your facebook account and at the same time there is a picture of an inappropriately dressed woman on the side advertising a product. You would not feel good right.
You can go on and on about social media, the bottom line is do not take it seriously guys.. and do not put too much of personal information over there.

Monday, 5 November 2012

Sweet not good

After hearing that the sweetness that comes out of even the fruits is not good for you, i just realized what a bad job the DNA scientists are doing by making the fruits sweet. These days when you eat a fruit you feel that you are eating something sweet, it doesnt have the flavour  or the aroma that we used to have in fruits that we ate earlier. My doctor says that even extremely sweet fruits are bad. Hence i ask the scientists to please leave the fruits alone. Do not make them sweet. Let them have their sweetness naturally...

Monday, 17 October 2011

Open documents like word, excel in asp.net

I was looking at ways to open word docs or excel docs in asp.net. Most of the solutions i found were related to using the Response object. Specifically using Response.Transmit.
Problem with Response.Transmit is that it does not work if your control is within UpdatePanel. Hence use the code below to open documents if your control is within updatepanel

string filePath = e.CommandArgument.ToString();
FileInfo fileInfo = new FileInfo(Server.MapPath(filePath));
string contentType = string.Empty;

if (fileInfo.Exists)
{
switch (fileInfo.Extension.ToLower())
{
case ".dwf":
contentType = "Application/x-dwf";
break;
case ".pdf":
contentType = "Application/pdf";
break;
case ".doc":
contentType = "Application/vnd.ms-word";
break;
case ".docx":
contentType = "Application/vnd.ms-word";
break;
case ".ppt":
contentType = "Application/vnd.ms-powerpoint";
break;
case ".pps":
contentType = "Application/vnd.ms-powerpoint";
break;
case ".xls":
contentType = "Application/vnd.ms-excel";
break;
case ".txt":
contentType = "Application/octet-stream";
break;
case ".jpg":
contentType = "image/jpeg";
break;
default:
break;
}
}
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = contentType;
Response.Redirect(filePath, true);

Friday, 10 June 2011

ASP.NET MVC handling session expiry


While working on my asp.net mvc application i came across the scenario wherein i could not handle the session expiry. I was using windows authentication and hence i could not redirect automatically to the login page on session expiry as it happens in forms authentication. If you have worked with MVC you would also find that redirecting is not as straight forward as response.redirect in normal webforms applications. Redirection does not work if there was an intercal AJAX call or partial postback.

To overcome the problem of session expiry in case of internal AJAX calls or partial postback i devised the following javascript solution.

This is a javascript function which calls a controller method. The controller method checks if the session exists and returns a flag accordingly

function CheckSession(url, urlR) {
var html = $.ajax(
{
type: "POST",
url: url,
dataType: 'html',
async: false,
data: {
},
success:
function(result) {
},
error: function(req, status, error) {
window.alert("There was an unexpected error while checking the existence of session. Kindly contact the help desk.");
}
}).responseText;
var status = true;
var resultFromController = html.split(',');
if (resultFromController[0] == 'False') {
alert('The session is expired. You will be now redirected to the Home Page.');
window.location = urlR;
status = false;
}
else if (resultFromController[0] == 'True') {
status = true;
}

return status;
};

The javascript function is called like this
var url = "<%= Url.Action("CheckSession", "Request") %>";
var urlR = "<%= Url.Action("Index", "Home") %>";

var session = CheckSession(url, urlR);

This is the Controller function that checks if the session exists
public ActionResult CheckSession()
{
ContentResult contentResult = new ContentResult();
if (Session[StringConstants.SAPSystems] == null)
{
contentResult.Content = StringConstants.False + StringConstants.Comma + "Session does not exists";
}
else
{
contentResult.Content = StringConstants.True + StringConstants.Comma + "Session exists";
}

return contentResult;
}