Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. SQL Server, Images and DataGrid in ASP.NET

SQL Server, Images and DataGrid in ASP.NET

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-netsql-servercom
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    postmaster programmingknowledge com
    wrote on last edited by
    #1

    How to upload Images to SQL Server database using ASP.NET tools. Also how to retrieve those saved images from SQL Server and display them onto DataGrid. Visit: http://www.programmingknowledge.com/ImageUpload.aspx

    C B 2 Replies Last reply
    0
    • P postmaster programmingknowledge com

      How to upload Images to SQL Server database using ASP.NET tools. Also how to retrieve those saved images from SQL Server and display them onto DataGrid. Visit: http://www.programmingknowledge.com/ImageUpload.aspx

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      postmaster@programmingknowledge.com wrote:

      How to upload Images to SQL Server database using ASP.NET tools.

      You can't put images in to SQL Server using ASP.NET. ASP.NET is a technology for writing web applications. It simply does not deal with the database. If you want to do anything with the database you must use ADO.NET.

      postmaster@programmingknowledge.com wrote:

      Visit: http://www....

      If you would like to advertise your website so blatantly then I suggest you buy advertising space.


      Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

      1 Reply Last reply
      0
      • P postmaster programmingknowledge com

        How to upload Images to SQL Server database using ASP.NET tools. Also how to retrieve those saved images from SQL Server and display them onto DataGrid. Visit: http://www.programmingknowledge.com/ImageUpload.aspx

        B Offline
        B Offline
        bgates1970
        wrote on last edited by
        #3

        This is for ASP.NET 1.1 but should be easy to convert to 2.0. The stored proc inserts the file into a blob/image field in the table. Imports System Imports System.Configuration Imports System.Data Imports System.Data.SqlClient Public Class AttachmentDB Private Function FileFieldSelected(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Boolean If FileField.PostedFile Is Nothing Then Return False If FileField.PostedFile.ContentLength = 0 Then Return False Return True End Function Private Function GetByteArrayFromFileField(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Byte() ' Returns a byte array from the passed ' file field controls file Dim intFileLength As Integer, bytData() As Byte Dim objStream As System.IO.Stream If FileFieldSelected(FileField) Then intFileLength = FileField.PostedFile.ContentLength ReDim bytData(intFileLength) objStream = FileField.PostedFile.InputStream objStream.Read(bytData, 0, intFileLength) Return bytData End If End Function Private Function FileFieldType(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As String ' Returns the type of the posted file If Not FileField.PostedFile Is Nothing Then _ Return FileField.PostedFile.ContentType End Function Private Function FileFieldLength(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Integer ' Returns the length of the posted file If Not FileField.PostedFile Is Nothing Then _ Return FileField.PostedFile.ContentLength End Function Private Function FileFieldFilename(ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As String ' Returns the core filename of the posted file If Not FileField.PostedFile Is Nothing Then _ Return Replace(FileField.PostedFile.FileName, _ StrReverse(Mid(StrReverse(FileField.PostedFile.FileName), _ InStr(1, StrReverse(FileField.PostedFile.FileName), "\"))), "") End Function Public Function InsertAttachment(ByVal fileID As Int32, ByVal FileField As System.Web.UI.HtmlControls.HtmlInputFile) As Int32 If Not FileFieldSelected(FileField) Then Return -1 End If Dim myConnection As SqlConnection = New SqlConnection(sqlconnection) Dim myCommand As SqlCommand = New SqlCommand(

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups