Hi..

In this article i am going to explain about How  to validate uploaded image in to database.For an every image contain  some unique Hexadecimal code,By comparing the code with upload image ,we can easily find out the image is real or not,Its one of the easiest technique i found.

For your refrence in previous article i explain about How to upload text file in database..
http://vbdotnetaddict.blogspot.com/2011/02/upload-file-in-aspnet-using-vb-coding.html

Follow the below process and code...


Before in SQL you have to create a table like this..
GO
CREATE TABLE [dbo].[upload](
 [fileid] [int] IDENTITY(1,1) NOT NULL,
 [ImageName] [varchar](max) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
 [Image] [image] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
'client side coding

 If FileUpload1.HasFile Then

                Dim imageSize As Byte()
                Dim intlength As Integer

           Dim bytes1() As Byte = pstFile(FileUpload1) 'This fuction is used to Read Bytes from the upload File


            If filech(bytes1) = False Then  'This Function used to check upload file is image or Not
                    Label1.Text = "Not Real Image file"
                    Exit Sub
                End If


                ' Create SQL Connection 
                Dim con As New SqlConnection()
                con.ConnectionString = ConfigurationManager.ConnectionStrings("phone").ConnectionString


                intlength = Convert.ToInt32(FileUpload1.PostedFile.InputStream.Length)
                Dim cmd As New SqlCommand()
                cmd.CommandText = "INSERT INTO upload(ImageName,Image) VALUES (@ImageName,@Image)"
                cmd.CommandType = CommandType.Text
                cmd.Connection = con
                Dim ImageName As New SqlParameter("@ImageName", SqlDbType.VarChar, 50)
                ImageName.Value = TextBox1.Text.ToString
                cmd.Parameters.Add(ImageName)

                Dim imagelenth As New SqlParameter("@Image", SqlDbType.Image)
                imagelenth.Value = bytes1
                cmd.Parameters.Add(imagelenth)
                con.Open()
                Dim result As Integer = cmd.ExecuteNonQuery()
                con.Close()

               
            Else

                Label1.Text = "please select the file to uplaod"
            End If

'This Function used to check upload file is image or Not........

 Function filech(ByVal byte1 As Byte()) As Boolean
        Dim fileheader As New Dictionary(Of String, Byte())
        fileheader.Add("JPG", New Byte() {&HFF, &HD8, &HFF, &HE0})
        fileheader.Add("JPEG", New Byte() {&HFF, &HD8, &HFF, &HE0})
        fileheader.Add("PNG", New Byte() {&H89, &H50, &H4E, &H47})
        fileheader.Add("TIF", New Byte() {&H49, &H49, &H2A, &H0})
        fileheader.Add("TIFF", New Byte() {&H49, &H49, &H2A, &H0})
        fileheader.Add("GIF", New Byte() {&H47, &H49, &H46, &H38})
        fileheader.Add("BMP", New Byte() {&H42, &H4D})
        fileheader.Add("ICO", New Byte() {&H0, &H0, &H1, &H0})

        Dim ext As String
        Dim tmp As Byte()
        Dim fheadr As Byte()


        If FileUpload1.HasFile Then
            ext = FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1).ToUpper
            tmp = fileheader(ext)
            fheadr = New Byte(tmp.Length - 1) {}

            For i As Integer = 0 To tmp.Length - 1
                If tmp(i) <> byte1(i) Then
                    Return False
                    Exit For
                Else
                    Return True
                End If
            Next
        End If
    End Function
'This fuction is used to Read Bytes from the upload File
Function pstFile(ByVal passfile As FileUpload) As Byte()
        Dim fs As Stream
        Dim bytes1 As Byte()
        Dim postfile As Byte()
        fs = passfile.PostedFile.InputStream
        Dim br1 As New BinaryReader(fs)
        bytes1 = br1.ReadBytes(passfile.FileContent.Length)
        postfile = bytes1
        Return postfile
    End Function


I hope this one really helpful to you........


hi....

i have been writing number of post about grid view.Now Here i am going to explain How to delete Multiple Records using check Box in grid view.
For your refrence In previous post i have written about How to update and Edit value in Grid View.

http://vbdotnetaddict.blogspot.com/2011/02/groid-view-load-and-update-sql-data.html

Steps To Follow.

First in client side you have to add grid view,add check box in Header tamplate and item template,Refer the below client Side coding

Second in Server side you have to add declare function checkbox selected index change ,this function used to select all the checkbox in the grid view.Refer the below server side coding ...

Client Side Coding :

<asp:GridView ID="GridView1" runat="server" 
            CellPadding="3" GridLines="Vertical" 
            AutoGenerateColumns="False" Height="155px" Width="582px" BackColor="White" 
                BorderColor="#999999" BorderStyle="None" BorderWidth="1px" 
                AllowPaging="True" DataKeyNames="Number" >
            <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="left" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="#DCDCDC" />
        <Columns >
        <asp:TemplateField  HeaderText ="s.no">
        <ItemTemplate >
        
                 <%# Container.DataItemIndex + 1 %>

        </ItemTemplate>
        
        
        
        </asp:TemplateField>
        
        <asp:BoundField HeaderText ="Phone Number" DataField ="Number" />
        
        <asp:TemplateField HeaderText ="NAME" >
                        <ItemTemplate >
                         <%#Eval("Name")%> 
                         </ItemTemplate>
                         <EditItemTemplate >
                         
                             <cc1:MacroWebTextBox ID="txtrwname" runat="server" Text ='<%#Bind("Name")%>' >   
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   
                                </cc1:MacroWebTextBox>
                         
                         </EditItemTemplate>
        
        </asp:TemplateField>
        
        <asp:TemplateField  HeaderText ="ADDRESS">
                        <ItemTemplate >
                        <%#Eval("Address")%>        
                        </ItemTemplate>  
                        <ItemStyle HorizontalAlign="Left" />      
                           <EditItemTemplate >
                           
                               <cc1:MacroWebTextBox ID="txtrwaddress" runat="server" Text='<%#bind("Address")%> ' Validate ="IsAlphaNum" ></cc1:MacroWebTextBox>
                           
                           </EditItemTemplate>     
        
        </asp:TemplateField>
        <asp:TemplateField HeaderTEXT="CITY" >
                        <ItemTemplate >
                        <%#Eval("City")%>
                        </ItemTemplate>        
                           <EditItemTemplate>
                               <cc1:MacroWebTextBox ID="txtrwcity" runat="server" Text='<%#bind("City")%>'></cc1:MacroWebTextBox>
                          
                           </EditItemTemplate>     
        
        </asp:TemplateField>
        
    <asp:TemplateField HeaderText ="STATE">
                        <ItemTemplate>
                         <%#Eval("State")%> 
                        </ItemTemplate>
                          <EditItemTemplate>
                          
                          
                              <cc1:MacroWebTextBox ID="txtrwstate" runat="server" Text='<%#bind("State")%> ' Validate ="IsAlphaNum ">
                               </cc1:MacroWebTextBox>
                              
                              </EditItemTemplate>
                              
  
  </asp:TemplateField>
  <asp:CommandField HeaderText ="modify" ShowDeleteButton ="false" ShowEditButton ="true" EditText ="modify" />
    
    <asp:TemplateField HeaderText="Delete">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkDelete" CommandName="Delete" runat="server" OnClientClick ="return confirm('are you sure')">Delete</asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                               
                               <asp:BoundField HeaderText ="Email" DataField ="email" />
                               
                                   <asp:TemplateField headertext="checkbox">
                                   <ItemTemplate >
                                   
                                    <asp:CheckBox ID="gridchkbox" runat="server" />
                                   </ItemTemplate>
                                     <HeaderTemplate>
                                         <asp:CheckBox ID="CheckBoxall" runat="server" AutoPostBack ="true" OnCheckedChanged ="checkbox1_checkedchanged"/>
                                     </HeaderTemplate>                                                   
                                
                                </asp:TemplateField>
       
        
        </Columns>    
        </asp:GridView>

Server Side Coding:

This code is used to delete the  selected record  in the grid view 

Protected Sub btndelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btndelete.Click
        Dim ch As CheckBox
        Dim number As String
        For i As Integer = 0 To GridView1.Rows.Count - 1
            ch = CType(GridView1.Rows(i).Cells(9).FindControl("gridchkbox"), CheckBox)
            If ch.Checked = True Then
                number = GridView1.Rows(i).Cells(1).Text
                sel = "Delete from phone where Number='" & number & "'"

               'Excute the query for delete the records
execute command(sel)
'
'
            End If
        Next
        loadde()
    End Sub

This code is used to select and Deselect CheckBox

 protected sub checkbox1_CheckedChanged (ByVal sender As Object, ByVal e As EventArgs)
        Dim chkbxall As CheckBox
        chkbxall = CType(GridView1.HeaderRow.FindControl("checkboxall"), CheckBox)
        If chkbxall.Checked = True Then
            For Each row As GridViewRow In GridView1.Rows

                Dim chkall As CheckBox
                chkall = CType(row.FindControl("gridchkbox"), CheckBox)

                If chkall.Checked = False Then
                    chkall.Checked = True
                End If
            Next
        Else
            For Each row As GridViewRow In GridView1.Rows

                Dim chkall As CheckBox
                chkall = CType(row.FindControl("gridchkbox"), CheckBox)

                If chkall.Checked = True Then
                    chkall.Checked = False
                End If
            Next

        End If
    End Sub


i hope this one helpful to you..

Plz post your valuable comments................


Google has announced +1 button for all site.Its very easy to add a button in blog and wordpres
Follow the below methods to add the button in you site..



Adding Google +1 Button on Blogspot

First Method.:

To add Google +1 button in blogspot blog , you need to login in your blog
Go to Dashboard
Then Click Design
Click Edit Html and Click expand widget Templates

Add the below code in <head> tag

<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>

Add the below code in <body> tag

<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="tall"></g:plusone>

Now save it...
you can enjoy the button with your Blog

Second Method :

To add Google +1 button in blogspot blog , you need to login in your blog
Go to Dashboard
Then click on your blog (if you have multi blogs running in same account)
Then click on Design.
Then you can see an option called “Add  A Gadget” click on it
Select a gadget with named “Html/ Javacript” so that you can add the Google +1 code in it
paste the following code in that gadget
<!– Place this tag in your head or just before your close body tag –><script type=”text/javascript” src=”http://apis.google.com/js/plusone.js”></script>
Save it

Adding Google +1 Button in wordpress
Logon to your wordpress admin.
Goto widgets
Select Text and drag to the location you need
paste the following code to get the google +1 button
<!– Place this tag in your head or just before your close body tag –><script type=”text/javascript” src=”http://apis.google.com/js/plusone.js”></script>
<!– Place this tag where you want the +1 button to render –><g:plusone size=”tall”></g:plusone>
Save it ,
Finally its done

Hence you finally added google +1 in your blogspot blogs