[ oracle ] password expired

Unlock password first

alter user user_name_naja account unlock;

Then set the new password

alter user user_name_naja identified by values 'encrypt_password_here_naja'

 

NOTE :

– I don’t know how to encrypt the password, so I set it to random number just to unlock the account and then use the oracle utilities to change the user password later.

– same password as before can be used as well

 

Advertisements

[ oracle ] ODAC

Since we have to use `Oracle Objects for OLE` we installed `ODAC`.

After we installed `ODAC 11.2.0.2.1 with Oracle Developer Tools for Visual Studio [ ODAC112021.zip ]`  ( not `ODAC 11.2.0.2.1 with Xcopy Deployment` ), I face some problems, and here is the solution.

Problem 1

After I installed

I face, oracle connection error

An error was encountered performing the requested operation:  IO Error: The Network Adapter could not establish the connection  Vendor code 17002

then I start LSNRCTL

LSNRCTL START

Error

TNS-12560: TNS:protocol adapter error
TNS-00530: Protocol adapter error

Solution 1

I forgot that I have to `run as administrator`,

LSNRCTL START

Problem 2

Now new error

An error was encountered performing the requested operation:

Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

Vendor code 12505

The result of lsnrctl services

C:\Windows\system32>lsnrctl services

LSNRCTL for 32-bit Windows: Version 11.2.0.2.0 - Production on 28-ต.ค. -2013 09:
18:42

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
The command completed successfully

I start all oracle service, the result is below

oracle_service_start

Result of tnsping

C:\oraclexe\app\oracle\product\11.2.0\server>tnsping xe

TNS Ping Utility for 32-bit Windows: Version 11.2.0.2.0 - Production on 28-ต.ค.
-2013 10:47:39

Copyright (c) 1997, 2010, Oracle.  All rights reserved.

Used parameter files:
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN\sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = User-PC)
(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
OK (20 msec)

Sounds like ping is OK.

After Stop and start database, everything is OK.

TIPS using SQLplus

sqlplus / as sysdba

[ oracle ] select version

For example,

select * from v$version;

Result

Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE    11.2.0.2.0    Production"
TNS for 32-bit Windows: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

In client use `TNSPing` or `sqlplus` DOS command

[ C#] MVC 2 101

Create New Project

In visual studio, File > New Project
`Visual C# Projects` and in the Templates pane, select `ASP.NET MVC 2 Web Application`.

The files will be generated.

SFA.sln
SFA\App_Data
SFA\bin
SFA\Content\Site.css
SFA\Controllers\AccountController.cs
SFA\Controllers\HomeController.cs
SFA\Global.asax
SFA\Global.asax.cs
SFA\Models\AccountModels.cs
SFA\obj\Debug
SFA\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
SFA\obj\Debug\Package
SFA\obj\Debug\TempPE
SFA\Properties\AssemblyInfo.cs
SFA\Scripts\jquery-1.4.1-vsdoc.js
SFA\Scripts\jquery-1.4.1.js
SFA\Scripts\jquery-1.4.1.min.js
SFA\Scripts\jquery.validate-vsdoc.js
SFA\Scripts\jquery.validate.js
SFA\Scripts\jquery.validate.min.js
SFA\Scripts\MicrosoftAjax.debug.js
SFA\Scripts\MicrosoftAjax.js
SFA\Scripts\MicrosoftMvcAjax.debug.js
SFA\Scripts\MicrosoftMvcAjax.js
SFA\Scripts\MicrosoftMvcValidation.debug.js
SFA\Scripts\MicrosoftMvcValidation.js
SFA\SFA.csproj
SFA\SFA.csproj.user
SFA\SFA.Publish.xml
SFA\Views\Account
SFA\Views\Home
SFA\Views\Shared
SFA\Views\Web.config
SFA\Views\Account\ChangePassword.aspx
SFA\Views\Account\ChangePasswordSuccess.aspx
SFA\Views\Account\LogOn.aspx
SFA\Views\Account\Register.aspx
SFA\Views\Home\About.aspx
SFA\Views\Home\Index.aspx
SFA\Views\Shared\Error.aspx
SFA\Views\Shared\LogOnUserControl.ascx
SFA\Views\Shared\Site.Master
SFA\Web.config
SFA\Web.Debug.config
SFA\Web.Release.config
----------------------------------------------------------------- UnitTest
SFA.Tests\App.config
SFA.Tests\bin
SFA.Tests\Controllers
SFA.Tests\obj
SFA.Tests\Properties
SFA.Tests\SFA.Tests.csproj
SFA.Tests\bin\Debug
SFA.Tests\Controllers\AccountControllerTest.cs
SFA.Tests\Controllers\HomeControllerTest.cs
SFA.Tests\obj\Debug
SFA.Tests\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
SFA.Tests\obj\Debug\TempPE
SFA.Tests\Properties\AssemblyInfo.cs

Build and Deploy

In Solution Manager, Right Click at the project > Build

Click `Start Debugging (F5)` icon

The default route

Global.asax.cs

routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

i.e. http://localhost:52386/Home/About calls method About()

in SFA\Controllers\HomeController.cs

 

Passing The data from controller to view

Controller

ViewData["Message"] = "Welcome to ASP.NET MVC!";

View

<%: ViewData["Message"] %>

Action Anchor

View

<%: Html.ActionLink("Register", "Register") %>

Form

View : Account/LogOn.aspx

NOTE : submit to Account/LogOn.aspx

<% using (Html.BeginForm()) { %>
<%: Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.") %>
<div>
<fieldset>
<legend>Account Information</legend>

<div>
<%: Html.LabelFor(m => m.UserName) %>
</div>
<div>
<%: Html.TextBoxFor(m => m.UserName) %>
<%: Html.ValidationMessageFor(m => m.UserName) %>
</div>

<div>
<%: Html.LabelFor(m => m.Password) %>
</div>
<div>
<%: Html.PasswordFor(m => m.Password) %>
<%: Html.ValidationMessageFor(m => m.Password) %>
</div>

<div>
<%: Html.CheckBoxFor(m => m.RememberMe) %>
<%: Html.LabelFor(m => m.RememberMe) %>
</div>

<p>
<input type="submit" value="Log On" />
</p>
</fieldset>
</div>
<% } %>

Model : AccountModels.cs

#region Models

public class LogOnModel
{
[Required]
[DisplayName("User name")]
public string UserName { get; set; }

[Required]
[DataType(DataType.Password)]
[DisplayName("Password")]
public string Password { get; set; }

[DisplayName("Remember me?")]
public bool RememberMe { get; set; }
}

#endregion

Properties Message

Web.config

i.e. minRequiredPasswordLength

<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>

 

 

[ C# ] create web project 101

New Project

In visual studio, File > New Project

`Visual C# Projects` and in the Templates pane, select `ASP.NET Web Application`.

The source will be generated,

About.aspx           #
About.aspx.cs
About.aspx.designer.cs
Account\ChangePassword.aspx
Account\ChangePassword.aspx.cs
Account\ChangePassword.aspx.designer.cs
Account\ChangePasswordSuccess.aspx
Account\ChangePasswordSuccess.aspx.cs
Account\ChangePasswordSuccess.aspx.designer.cs
Account\Login.aspx                     #
Account\Login.aspx.cs
Account\Login.aspx.designer.cs
Account\Register.aspx                #
Account\Register.aspx.cs
Account\Register.aspx.designer.cs
Account\Web.config
App_Data
bin
Default.aspx                          #
Default.aspx.cs
Default.aspx.designer.cs
Global.asax
Global.asax.cs
obj\Debug
obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
obj\Debug\TempPE
Properties\AssemblyInfo.cs
Scripts\jquery-1.4.1-vsdoc.js
Scripts\jquery-1.4.1.js
Scripts\jquery-1.4.1.min.js
SFA.csproj
SFA.csproj.user
Site.Master
Site.Master.cs
Site.Master.designer.cs
Styles\Site.css
Web.config
Web.Debug.config
Web.Release.config

Build and Deploy

In Solution Manager, Right Click at the project > Build

In Solution Manager, Right Click at the project > View in Browser

Add New Page

right click project > Add > New Item

.. Web Form

The files will be generated.

PongTest.aspx – the visual representation
PongTest.aspx.cs or PongTest.aspx.vb – Code for event handling

PongTest.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PongTest.aspx.cs" Inherits="SFA.PongTest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

 PongTest.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SFA
{
public partial class PongTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
}

ref : microsoft