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
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to upload excel sheet (.xlxs) to sql server 2012 with vb.net and asp.net

How to upload excel sheet (.xlxs) to sql server 2012 with vb.net and asp.net

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-netsql-server
4 Posts 4 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.
  • B Offline
    B Offline
    Bocus Iqbal
    wrote on last edited by
    #1

    Hello All, It is my first time that am posting a question here. I have research a lot on the web on how to upload excel sheet (.xlxs) to sql server 2012 database through asp.net and vb.net, however, unfortunately all those research was of no use. can someone please help me with the source code. thanks.

    C L C 3 Replies Last reply
    0
    • B Bocus Iqbal

      Hello All, It is my first time that am posting a question here. I have research a lot on the web on how to upload excel sheet (.xlxs) to sql server 2012 database through asp.net and vb.net, however, unfortunately all those research was of no use. can someone please help me with the source code. thanks.

      C Offline
      C Offline
      CHill60
      wrote on last edited by
      #2

      If your research was of no use what makes you think anything we say here will be of use to you? We are not a code-writing service. This article should get you started - Upload and Download Files with SQL Server in ASP.NET[^] If you have a specific question after trying this by all means come back with the code you are having a problem with

      1 Reply Last reply
      0
      • B Bocus Iqbal

        Hello All, It is my first time that am posting a question here. I have research a lot on the web on how to upload excel sheet (.xlxs) to sql server 2012 database through asp.net and vb.net, however, unfortunately all those research was of no use. can someone please help me with the source code. thanks.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        See if this work for you - Storing and Retrieving doc/pdf/xls files in SQL Server | Tech Treasure[^]

        1 Reply Last reply
        0
        • B Bocus Iqbal

          Hello All, It is my first time that am posting a question here. I have research a lot on the web on how to upload excel sheet (.xlxs) to sql server 2012 database through asp.net and vb.net, however, unfortunately all those research was of no use. can someone please help me with the source code. thanks.

          C Offline
          C Offline
          ChetanAhire
          wrote on last edited by
          #4

          Use fileupload control and on submit button call below function and save the data in db in binary format. Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As EventArgs) ' Read the file and convert it to Byte Array Dim filePath As String = FileUpload1.PostedFile.FileName Dim filename As String = Path.GetFileName(filePath) Dim ext As String = Path.GetExtension(filename) Dim contenttype As String = String.Empty 'Set the contenttype based on File Extension Select Case ext Case ".doc" contenttype = "application/vnd.ms-word" Exit Select Case ".docx" contenttype = "application/vnd.ms-word" Exit Select Case ".xls" contenttype = "application/vnd.ms-excel" Exit Select Case ".xlsx" contenttype = "application/vnd.ms-excel" Exit Select Case ".jpg" contenttype = "image/jpg" Exit Select Case ".png" contenttype = "image/png" Exit Select Case ".gif" contenttype = "image/gif" Exit Select Case ".pdf" contenttype = "application/pdf" Exit Select End Select If contenttype <> String.Empty Then Dim fs As Stream = FileUpload1.PostedFile.InputStream Dim br As New BinaryReader(fs) Dim bytes As Byte() = br.ReadBytes(fs.Length) 'insert the file into database Dim strQuery As String = "insert into tblFiles" _ & "(Name, ContentType, Data)" _ & " values (@Name, @ContentType, @Data)" Dim cmd As New SqlCommand(strQuery) cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = filename cmd.Parameters.Add("@ContentType", SqlDbType.VarChar).Value _ = contenttype cmd.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes InsertUpdateData(cmd) lblMessage.ForeColor = System.Drawing.Color.Green lblMessage.Text = "File Uploaded Successfully" Else lblMessage.ForeColor = System.Drawing.Color.Red lblMessage.Text = "File format not recognised." _ & " Upload Image/Word/PDF/Excel formats" End If End Sub

          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