Tuesday, July 20, 2010

Filtering the data from datatable using the dataview

How to use a data view in c#

Here is a sample code which shows how to use the dataview in c# for filtering the data


protected void btnSubmit_Click(object sender, EventArgs e)
{
DataSet dsStates = null;
DataView dvRow = null;
try
{
dsStates = new DataSet();
dsStates.ReadXml( Path.Combine(Request.PhysicalApplicationPath , "xmlfile.xml"));
dvRow = dsStates.Tables[0].DefaultView;
dvRow.RowFilter = "state_Text='a'";
TextBox1.Text = dvRow.Table.Rows[0].ItemArray[0].ToString();
}
catch (Exception )
{

throw ;
}
finally
{
dsStates = null;
dvRow = null;
}
}



Description:
From above we are forming the datatable from the xml file, and from the datatable we are filtering the data into the dataview using the dataview's row filter method.


Note:
Good coding practices from the above code are:
1) While combining the path then use the Path.Combine method which is present in the System.IO namespace.
2) Use exceptional handling.
3) Clear the data in the finally block.

Monday, July 12, 2010

ORA-01033: ORACLE initialization or shutdown in progress

This error generally occurs when you newly install the oracle server edition with some improper settings, And you may also get this error when you do some changes in the "ADMINISTATION ASSISTANT FOR WINDOWS" option which comes after installing the oracle server.

The simple solution is:

Sol I:

Login the data base using the sys user, this user is powerful enough to login even the above error occurs (you get an warning message at the time of login- click ok and proceed )
and then type the following query and run it

alter database open

and commit the transaction.


Sol II:
Do the following things

Executed command no & o/p are listed here.


1- SQL> shutdown abort
O/P- ORACLE instance shut down.

2- SQL> start database step by step
O/P- SP2-0310: unable to open file "database.sql"

3- SQL> startup nomount
ORACLE instance started.

Total System Global Area 118255568 bytes
Fixed Size 282576 bytes
Variable Size 83886080 bytes
Database Buffers 33554432 bytes
Redo Buffers 532480 bytes


4- SQL> alter database mount;

Database altered.

5- SQL> alter database open;






OR IF YOU DONT EVEN REMEMBER THE SYS USER PASSWORD, THEN GO TO RUN AND EXECUTE THE FOLLOWING COMMANDS..........


1)
C:\>cd oracle

C:\oracle>

2)

C:\oracle>cd ora92

C:\oracle\ora92>cd bin

C:\oracle\ora92\bin>set ORACLE_SID=OID

C:\oracle\ora92\bin>set ORACLE_HOME=C:\Oracle\ora92


3)
C:\oracle\ora92\bin>sqlplus /nolog

4)
SQL> connect / as sysdba
Connected.



Now you have logged in into the sys user.


And now run this query- Alter database open;

now your database gets opened and now you can login into the database.
SQL>




note: In few systems only 1st step is enough and after that go with the 4th step as :C:\oracle>sqlplus /nolog.