Friday 8 June 2012

How to save a file from HTML File Control in AJAX Section Using ASP.Net with C#



    •     AJAX stands for Asynchronous  Java script and XML  
    •    AJAX enable a page asynchronously post back a page.  
    •   Only required part load from server instead of entire page so its   increase web performance.
    • Some control which are design for post back like file browser which can’t load a file if its not post back so you can’t upload a file when it’s in AJAX section.

        For upload a file in AJAX section using file browser you need to register a button for post back if user will click on than button then all page will be reloaded.
      <asp:UpdatePanel ID="U1" runat="server">
                <ContentTemplate>
      ....................................
      ....................................
               </ContentTemplate>
         <Triggers> 
             <asp:PostBackTrigger ControlID="saveButton">
         </Triggers>  
      </asp:UpdatePanel> 
      Here is your html code i leave ...... for your content Savebutton is a which post back entire page
      So i registered this button in trigger section post backTrigger register control which have to post back.....

Wednesday 6 June 2012

Create Album Using Java Script with fade effect



Hi.................
This post will help you to make a picture album.Pictures of album will change during a second internal.
I have done this with the help of java script.
  • This post will create a static album in nature you can't add a new image at run time if you want to add or remove image you will have to change java script code.
  • Save your picture in a folder and rename all picture into 1 to increasing order e.g (1.jpg , 2. jpg ,3,jpg...)
  • Count no. of picture in your folder because I'll use this number in java script code block
  • I used a timer which will run continue you can not stop it

Image Slide Show Using HTML

This is a presentation of a image slide show.This blog will help
you to make a moveable slide show right to left
This is a flat HTML coding.
This is achieve by marquee tag.Marquee tag has capacity to move any type of object inside it.I used marquee for make this slide show.


       

  • I saved my HTML file and all image in a folder so used relative path
  • if your image isn't in current folder then you need to provide full path of that image.....
   






Monday 4 June 2012

Save and Retrieve an image in Ms Access Using VB.Net

Hi.......
Its very simple to save and retrieve image in ms access for performing save retrieve you need to do something as mention...........
  • Aceess store image in binary format
  • We've to convert an image into binary at save time and binary ti bitmap at retrieve time

Database Table Structure 

 

 

 

 

 

 

 

 

 

  


Saturday 2 June 2012

Retrieve an Image from SQL Server in Picture Box Using VB.Net

Hi, There
Retrieving an image from sql server database is so simple just do following steps
  • Make a project and database which i mention in my Blog Take a look 
  • Add a picture box on your form, and a button for show image
  • On Show Button Click event paste following code

Friday 1 June 2012

Save an Image in SQL Server Database With VB.Net

Hi
Saving Image is an important part of any software,They're many ways to handling image.One easy and secure way is save your image in sql server database.If you want to save image in sql server then follow these steps
  • Make a database and a table with following description my database name is bsw and table name is stu
Database Table Structure

VB Project Controls Which you have to use
  •  You have to import 2 name space
    Imports System.IO
    Imports System.Data.SqlClient
  • Add OpenFileDialog control
  • And make a global string variable named str
    • On Browse picture button click paste following code
        OpenFileDialog1.ShowDialog()
         str = OpenFileDialog1.FileName
On Click event of save button paste following code


Dim con As New SqlConnection("initial catalog=bsw;data source=.;integrated security=true") Dim com As New SqlCommand()
Try
            Dim fs As New        FileStream(str,FileMode.Open)
            Dim data() As Byte = New [Byte](fs.Length) {}
            fs.Read(data, 0, fs.Length)
            fs.Close()
            'readed image
            Dim roll As New SqlParameter("roll", SqlDbType.Int)
            roll.Value = Val(TextBox1.Text)

            Dim name As New SqlParameter("name", SqlDbType.Char, 10)
            name.Value = TextBox2.Text

            Dim city As New SqlParameter("city", SqlDbType.Char, 10)
            city.Value = TextBox3.Text

            Dim img As New SqlParameter("img", SqlDbType.Image)
            img.Value = data
            'Adding parameters
            com.Parameters.Add(roll)
            com.Parameters.Add(name)
            com.Parameters.Add(city)
            com.Parameters.Add(img)
            con.Open()
            com.Connection = con
            com.CommandText = "insert into stu values(@roll,@name,@city,@img)"
            com.ExecuteNonQuery()
            MsgBox("Saved")
            Me.StuTableAdapter.Fill(Me.BswDataSet1.stu)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Tuesday 21 February 2012

Complete menu based java database program for read,write,delete,update


hi folks
this is complete menu based program  java database read write.You'll have to set odbc driver which i have mention in java database connection blog
paste following code in your editor compile and run.....

import java.sql.*;
import java.io.*;
class dataoperation
{
        String nm,ct,db,cls;
        int rl;
        Connection con=null;      
        DataInputStream da=new DataInputStream(System.in);
        Statement stmt=null;
        dataoperation()
        {
                cls="sun.jdbc.odbc.JdbcOdbcDriver";
                db="jdbc:odbc:mydata";
                try
                {
                        Class.forName(cls);
                        con=DriverManager.getConnection(db,"","");
                        stmt=con.createStatement();
                }
                catch(Exception ex)
                {
                        System.out.println("Error : "+ex.getMessage());
                }
               
        }
        void write()
        {
                try
                {
                     
                        System.out.print("Enter Roll ");
                        rl=Integer.parseInt(da.readLine());
                        System.out.print("Enter name  ");
                        nm=da.readLine();
                        System.out.print("Enter city ");
                        ct=da.readLine();
                      
                        stmt.executeUpdate("insert into stu values("+rl+",'"+nm+"','"+ct+"')");
                        System.out.println("\nInserted");
                      
                }
                catch(Exception ex)
                {
                    System.out.println("Error : "+ex.getMessage());
                }
               
        }
        void delete()
        {
            System.out.println("Enter Roll ");
           
            try
            {
                rl=Integer.parseInt(da.readLine());
                stmt.executeUpdate("delete from stu where roll="+rl);
            }
            catch(Exception ex)
            {
                System.out.println("Error : "+ex.getMessage());
            }
        }
        void update()
        {
            try
            {
                System.out.print("Enter roll ");
                rl=Integer.parseInt(da.readLine());
                System.out.print("Enter Name ");
                nm=da.readLine();
                System.out.print("Enter City ");
                ct=da.readLine();
                stmt.executeUpdate("update stu set name='"+nm+"', city='"+ct+"' where roll="+rl);
               // con.close();
                System.out.print("\nRecord Updated");
            }
            catch(Exception ex)
            {
                System.out.print("\nError"+ex.getMessage());
            }
        }
        void print()
        {
            System.out.println("\n\n********* OUTPUT *************");
            try
            {
                ResultSet rlt=stmt.executeQuery("select * from stu");
                while(rlt.next())
                {
                    System.out.print("\t"+rlt.getString(1)+" "+rlt.getString(2)+" "+rlt.getString(3)+"\n");
                }
            }
            catch(Exception ex)
            {
                System.out.print("\nError : "+ex.getMessage());
            }
            System.out.println("\n****************************\n\n");
        }
}


class dbcomplete
{
   
   
    public static void main(String[] args) throws Exception
    {
       int opt;
       DataInputStream da=new DataInputStream(System.in);
       dataoperation ob=new dataoperation();
       do
       {
           System.out.println("****************************************");
           System.out.print("\n1. Add\n2. Delete\n3. Update\n4. Print\n0. Exit\n****************************************");
           System.out.print("\nEnter Your choice ");
           opt=Integer.parseInt(da.readLine());
           switch(opt)
           {
               case 1:
                    ob.write();
                    break;
               case 2:
                   ob.delete();
                   break;
               case 3:
                   ob.update();
                   break;
               case 4:
                   ob.print();
                   break;
               case 0:
                   break;
               default:
                   System.out.print("\nInvalid choice");
           }
          
       }while(opt!=0);
    }
   
}

Thursday 16 February 2012

How to delete record from Ms Access in Java








rajkumar9795@gmail.com
for delete a record in access follow instruction as mention in file connection blog 

Monday 13 February 2012

Connect Ms Access 2003 with Java (jdk1.3)


Hi
friends and student
 i was thinking from a long time how can i connect jdk1.3 to database.
Its very exciting and easy... Plz do following steps
1. Make a database in Ms Access
2. My Database name is bsw and table named stu(name,city)
3. Open Control panel>Administor>Data Sources(ODBC)
4.Select Ms Access (*.mdb) > Add
5. Write appropriate name of your ODBC Name
6. Select Database from select button
7. Paste this code,compile run and enjoy your database Connectivity


import java.sql.*;
import java.io.*;
class con2test
{
             public static void main(String[] args)
             {
                         // change this to whatever your DSN is
                         String dataSourceName = "mdbTEST";  //mdbTest is name which u hv mention in odbc data source name window
                         String dbURL = "jdbc:odbc:" + dataSourceName;
                         try
                        {
                                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                    Connection con = DriverManager.getConnection(dbURL, "","");    

                                     
                                    String nm;
                                    DataInputStream da=new DataInputStream(System.in);
                                    System.out.print("Enter name ");
                                    nm=da.readLine();
                                    System.out.print("Enter address ");
                                    address=da.readLine();
                                    Statement s = con.createStatement();
                                    s.executeUpdate("insert into user

values('"+nm+"','"+address+"')");
                                    con.close();
                                    System.out.println("Saved");
                                 
                         }
                         catch (Exception err)
                        {
                                    System.out.println( "Error: " + err );
                         }
             }
}