Sunday, December 27, 2009

Image upload in Oracle

Why we upload image in database not in server? search www.google.com 


Here is a sample project that upload image from your local machine and then it uploaded in oracle database. If you want to save the file in server and database then remove the comment at the following line and line number :

 Default.aspx.cs ->line number : 23,24,41,42 


If you want to upload the images server then same file name is uploaded previous is overwritten. But it will still in database. 


Process :
1. Connect oracle in asp.net. To connect oracle in asp.net see here.


2. From previous there is small change in OracleConnect.cs file . A overloaded method is added.  you can download the file from here.

4. A generic handler file is added here to show the image. why it is used? see www.google.com


5. To run the sample project( here ) you need to change the databasename, username and password 4 times. Here is the file names and line numbers
( I used Database name as "XE" username as "project" and password is "12345")


Default.aspx.cs -> line no : 13
MyHandler.ashx->line no : 23
ShowImage.aspx.cs->Line no : 12,32


6. The table schema is here.


7. To show the images you can use GridView ,ListView, DataList, Repeater controls. I used the repeater control. Other controls are used but they are commented. If u want to see the other controls then remove comment in ShowImage.aspx and ShowImage.aspx.cs



So do it. See the sample project and run.
Attachments:
1. sample project 
2. Table schema
3. OracleConnect.cs

For any query comment here or mail "humayun0156@gmail.com" 

Login Controls in ASP.NET using Oracle

In asp.net The Login controls does automatic using MSSql. Now we want to use Oracle.

1. Create a new project.

2. Connect it to oracle. If you don't know how to connect oracle in asp.net please see this link

3. In web.config file change the following line From

   <authentication mode="Windows"/>     To   
   <authentication mode="Forms"/>

4. Now you want to view some content who are logged in. But those are not logged in they do not see that content. So, add a LoginView control. Go to Source view.

 <asp:LoginView ID="LoginView1" runat="server">
                        <AnonymousTemplate>
                            Welcome guest.You are not logged in. To view the page please loggin.
                        </AnonymousTemplate>
                       
                        <LoggedInTemplate>
                            Welcome :
                            <asp:LoginName ID="LoginName2" runat="server" />
                        </LoggedInTemplate>                      
                    </asp:LoginView>



5. I have created a Private_Page.aspx that will only show the people who have logged in. If you are not logged in but u want to access the page using URL like "http://localhost/Private_Page.aspx" then u r redirect to login page. But if u are logged in and access the private page using URL then u will be able to view the page.


6. If u have many pages and u want to show that the people whether logged in or not , just put on the page a LoginStatus control. 


7. If you show the user name just put on a LoginName control.


8. You should not do anything for loginstatus or loginname, just put this two control.


9. I have uploaded a sample project. If any query mail me or comment here.

Here Is the sample project



Regards
Md. Humayun Kabir

Saturday, December 26, 2009

How To Connect Oracle in ASP.NET

1. Create a new web site.

2. In solution explorer right click and click Add Reference. Then select "System.Data.OracleClient" namespace

3. Then Create a new class file(.cs) and
the class file automatically create under a folder named App_Code. Copy all content of the file "OracleConnect.cs" (provided) and paste them in your new created class(.cs) file.

4. Then you are done.

5. A sample project is provided.


Attachments:
1. OracleConnect.cs
2. A sample Project


Remember:
1. Don't Forget to change your oracle username and password in sample project.
2. In Oracle 10g Express edition database name is "XE" ( default )

Regards
Md. Humayun Kabir
Department of CSE
BUET