Monday, November 29, 2010

Renaming a column using oracle from version 9i

ALTER TABLE <TABLE_NAME> RENAME COLUMN <CURRENT_COLUMN_NAME> TO<NEW_COLUMN_NAME>;

Thursday, November 11, 2010

TO_DATE Oracle Function

Syntax: TO_DATE (date, format) 

 

Example: TO_DATE('11/11/2010 13:00:00', 'dd/MM/YYYY HH24:MI:SS')  - in this case for 24 hours. For 12 hours, you should also specify AM or PM.

 

Find out more in this website (another one that I hope lasts forever) - http://www.techonthenet.com/oracle/functions/to_date.php

 

 

Oracle JDBC string Connection for thin driver

Simple, simple (I took too much time trying to find this string)…

 

jdbc:oracle:thin:[user/password]@//[host][:port]/SID

 

Friday, October 29, 2010

String connection for Microsoft ODBC for Oracle

Direct connection, no DSN, no TSN:

Driver={Microsoft ODBC for Oracle};Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=199.199.199.199)(PORT=1523))(CONNECT_DATA=(SID=dbName)));Uid=sqv;Pwd=sqv;

 

Extract from: http://www.connectionstrings.com/oracle#p17 (very good website)

 

Monday, October 25, 2010

Bulleted lists, numeric lists, etc - HTML Tutorial

I found a very good interesting website teaching how to create lists using only html.
I know, it's simple, but I've never used. Since the number of ASP.NET MVC applications are growing, is always good to know...

I used bulleted lists. You can use the following tag: <ul><li></li></ul>. For the other types, check the website, there is a very good a simple tutorial...

http://www.echoecho.com/htmllists.htm

Friday, October 22, 2010

SQL Injection

This video is really good.
I've known about SQL Injection but I've never seen how they do it. The instructor give good tips to avoid it!

http://www.asp.net/security/videos/sql-injection-defense

This is a real example of what could happen:

http://www.itworldcanada.com/news/hacker-steals-e-mail-addresses-demands-astley-tune/140705

Tuesday, October 5, 2010

How to avoid ctrl+c or ctrl+v on a field (javascript)

I've found this code somewhere (I don't remember the website and I
lost the address), and it's very simple and useful:

You can create this function in javascript:

<script language="javascript" type="text/javascript>
function onKeyDown() {
var pressedKey = String.fromCharCode(event.keyCode).toLowerCase()
if (event.ctrlKey && (pressedKey == 'c' || pressedKey == 'v')) {
event.returnValue = false;
}
}
</script>

text tag in a asp.net page
<asp:TextBox ID="txtText" runat="server" Width="80px" MaxLength="10"
onKeyDown="onKeyDown()" ></asp:TextBox>

Friday, September 17, 2010

Regular expressions website

This website is really good!
I found regular expressions for email checking, credit card, almost
everything! And there is also a tutorial (something that I should
study)...
http://www.regular-expressions.info/creditcard.html

Wednesday, July 7, 2010

function to get Month name in C#

I'm reproducing just part of the code:
 
string sDate = iMonth.ToString() + "/01/" + iYear.ToString();

DateTime dtDate = Convert.ToDateTime(sDate);

lblMonth.Text = dtDate.ToString("MMMM");

It's not difficult, right? But I took some time to find the answer in a forum...

 

 

Monday, June 21, 2010

concatenating strings in Oracle

Different from SQL, there is a function to concatenate strings in Oracle. Here it is:

Concat(str1, str2) - only two arguments!

For example

Table City_Province

CityName Province
Toronto ON
North York ON

Select Concat (CityName, Province) as City from City_Province;

Results:

TorontoON
NorthYorkON

But, if you want some spaces and commas or stuff like that between the fields (of course you want), you can do this:

Select CityName || ',' || Province as City from City_Province

Results:

Toronto,ON
NorthYork,ON

Much better, isn't it?

Sunday, April 18, 2010

JavaScript debugger

To debug a page with javascript, you can use firebug:

https://addons.mozilla.org/pt-BR/firefox/addon/1843

According to my friend MMs, it's really a God's thing!

Monday, April 12, 2010

Nortel VPN message: Unable to reach server

After struggling some time with this problem, I found in a forum the solution!
For those who have Windows Vista, you should stop the ICS (Internet Connection Sharing) Service. And... that's it! So simple!

Wednesday, March 31, 2010

sp_helptext in Oracle

To get a result similar to sp_helptext SQL Server procedure in Oracle, you can use the following query:

 

SET LINESIZE 132
SET LONG 4000
SELECT TEXT 
  FROM ALL_SOURCE
 WHERE NAME = 'YOUR_PROCEDURE_NAME'

 

If you have another solution, please let me know… I didn’t find anything better than this…

PS: You should use the command window to be able to execute this query

Monday, March 22, 2010

XSD generator (converts XML to an XSD file)

For those who needs an XSD file and doesn’t have enough time to learn how to do it, you can use the functions in this website to get your xml converted in xsd:

 

http://www.hitsw.com/xml_utilites/

 

 

Thursday, March 4, 2010

Regular Expressions Code Template in VBScript

The template below is to be used when you have a string and you want to get date information.

varString = the original string that will be used
iItem = Number of ocurrency (1 = first , 2 = second and so on)
sDate = The date time based on a month retrieved from the original string.

Example: 12345 12MAR 25APR 3MAY (Remember: the months are in English)…

Function CheckDate(varString, iItem, sDate)

    Dim iIndex
    Dim objRegExp, objMatch, objMatches
    Dim sDay
    Dim iMonthChar
    Dim bIsDate
    Dim strMonths
    Dim strMonth
   
    bIsDate = False
    'check if the string contains a month
    Set objRegExp = CreateObject("VBScript.RegExp")
    objRegExp.Pattern = "JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC"
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
   
    'get the matches if there be
    Set objMatches = objRegExp.Execute(varString)
    iIndex = 1
    For Each objMatch In objMatches
        If iIndex = iItem Then
            strMonth = objMatch.value
            iMonthChar = objMatch.FirstIndex
            Exit For
        Else
            iIndex = iIndex + 1
        End If
    Next
    
    If strMonth = "" Then
        sDate = ""
    Else
        sDay = Mid(varString, iMonthChar - 1, 2)
        If IsNumeric(sDay) Then
            sDate = GetFormattingData(sDay & strMonth, False)
            bIsDate = IsDate(sDate)
        End If
    End If
     CheckDate = bIsDate
 End Function

Controlling oracle transactions using VBScript

Very nice sample!

 

http://dev-notes.com/code.php?q=67

 

You can also use Oracle OleDBprovider, it is not mandatory to use MSDAORA.

 

 

Tuesday, March 2, 2010

How to create/drop/enable/disable a primary key in oracle

Hopefully this link works forever, hahahahaha

 

http://www.techonthenet.com/oracle/primary_keys.php

 

 

Friday, February 5, 2010

Problems with Oracle.DataAccess

Error Message: Could not load file or assembly 'Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.

Platform: .net framework 3.5

Application type: console application

Database: Oracle 10

Language: C#

IDE: Visual Studio 2008.

Yesterday, I finished my console application in C#, I built it and I saw in the Debug Folder, the Oracle.Data.dll. I thought it strange because, normally if the dll exists in your computer you don’t need to install the dll together with the executable file.

And… It’s true! If you don’t have any problems with the dll, you don’t need to move the dll with the executable.

What I did: I just use the Global Assembly Cache Tool (gacutil.exe) - the .net version of regsvr32.exe and that’s it. I restarted the Visual Studio 2008 again and It worked.

The exact command that I used was:

gacutil /if C:\oracle\product\10.2.0\client_1\odp.net\bin\2.x\Oracle.DataAccess.dll

the /if option means that you want to install an assembly into the global assembly cache. If an assembly with the same name already exists in the global assembly cache, the tool overwrites it.

You can find out more about the Global Assembly Cache, clicking here

Tuesday, January 19, 2010

Error while attempting to create an windows xp user

“The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. Check the minimum password length, password complexity and password history requirements”.

This error message means that you are not following the password requirements. But how can you find out what the requirements are?

Follow the instructions below:

            Find out what are the password policy requirements:

-         Start >> Control Panel >> Administrative Tools >> Local Security Policy

o       In Account Policies folder, select Password Policy  and you can see the password requirements.

In this way, you can also change the requirements and reduce or increase the complexity.

 

 

Friday, January 15, 2010

Enabling file and directory name completion

File and directory name completion is not enabled by default. You can enable or disable file name completion for a particular process of the cmd command with /f:{on|off}. You can enable or disable file and directory name completion for all processes of the cmd command on a computer or user logon session by setting the following REG_DWORD values:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD 

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD 

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar\REG_DWORD 

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\PathCompletionChar\REG_DWORD 

To set the REG_DWORD value, run Regedit.exe and use the hexadecimal value of a control character for a particular function (for example, 0×9 is TAB and 0×08 is BACKSPACE). User-specified settings take precedence over computer settings, and command-line options take precedence over registry settings.