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. Connecting to an Excel spreadsheet via HTTP

Connecting to an Excel spreadsheet via HTTP

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestionworkspace
6 Posts 2 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.
  • J Offline
    J Offline
    jphuphilly
    wrote on last edited by
    #1

    CAn anyone help me? ' Create variables that are used in code sample. Dim i, j As Integer ' Create connection string variable. Modify the "Data Source" parameter as ' appropriate for your environment. Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=http:\\myserver\get.csv;" & "Extended Properties=Excel 8.0;" ' Create the connection object by using the preceding connection string. Dim objConn As New OleDbConnection(sConnectionString) ' Open connection with the database. objConn.Open() ' The code to follow uses a SQL SELECT command to display the data from the worksheet. ' Create new OleDbCommand to return data from worksheet. Dim objCmdSelect As New OleDbCommand("SELECT * FROM myRange1", objConn) ' Create new OleDbDataAdapter that is used to build a DataSet ' based on the preceding SQL SELECT statement. Dim objAdapter1 As New OleDbDataAdapter ' Pass the Select command to the adapter. objAdapter1.SelectCommand = objCmdSelect ' Create new DataSet to hold information from the worksheet. Dim objDataset1 As New DataSet ' Fill the DataSet with the information from the worksheet. objAdapter1.Fill(objDataset1, "XLData") ' Build a table from the original data. dgTest.DataSource = objDataset1.Tables(0).DefaultView dgTest.DataBind() ' Clean up objects. objConn.Close() Da Intern

    M 1 Reply Last reply
    0
    • J jphuphilly

      CAn anyone help me? ' Create variables that are used in code sample. Dim i, j As Integer ' Create connection string variable. Modify the "Data Source" parameter as ' appropriate for your environment. Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=http:\\myserver\get.csv;" & "Extended Properties=Excel 8.0;" ' Create the connection object by using the preceding connection string. Dim objConn As New OleDbConnection(sConnectionString) ' Open connection with the database. objConn.Open() ' The code to follow uses a SQL SELECT command to display the data from the worksheet. ' Create new OleDbCommand to return data from worksheet. Dim objCmdSelect As New OleDbCommand("SELECT * FROM myRange1", objConn) ' Create new OleDbDataAdapter that is used to build a DataSet ' based on the preceding SQL SELECT statement. Dim objAdapter1 As New OleDbDataAdapter ' Pass the Select command to the adapter. objAdapter1.SelectCommand = objCmdSelect ' Create new DataSet to hold information from the worksheet. Dim objDataset1 As New DataSet ' Fill the DataSet with the information from the worksheet. objAdapter1.Fill(objDataset1, "XLData") ' Build a table from the original data. dgTest.DataSource = objDataset1.Tables(0).DefaultView dgTest.DataBind() ' Clean up objects. objConn.Close() Da Intern

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      jphuphilly wrote:

      CAn anyone help me?

      The answer may have to be "no" - unless you want to actually ask a programming question ;P Was there something specific in your code that wasn't working? Was there something specific that you didn't understand about the code you posted? I think you'll find that if you ask questions about specific things you'll have a much better chance of getting a relevant answer.

      J 1 Reply Last reply
      0
      • M Mike Ellison

        jphuphilly wrote:

        CAn anyone help me?

        The answer may have to be "no" - unless you want to actually ask a programming question ;P Was there something specific in your code that wasn't working? Was there something specific that you didn't understand about the code you posted? I think you'll find that if you ask questions about specific things you'll have a much better chance of getting a relevant answer.

        J Offline
        J Offline
        jphuphilly
        wrote on last edited by
        #3

        I apologize forgot the most important part the error message this is the error message i recieve when i try to run the attached code. System.Data.OleDb.OleDbException: Invalid internet address. Da Intern

        M 1 Reply Last reply
        0
        • J jphuphilly

          I apologize forgot the most important part the error message this is the error message i recieve when i try to run the attached code. System.Data.OleDb.OleDbException: Invalid internet address. Da Intern

          M Offline
          M Offline
          Mike Ellison
          wrote on last edited by
          #4

          Okay... it seems pretty clear then that ADO.NET is not reconizing the address you're using in your connection string as valid.

          Data Source=http:\\myserver\get.csv;"

          J 1 Reply Last reply
          0
          • M Mike Ellison

            Okay... it seems pretty clear then that ADO.NET is not reconizing the address you're using in your connection string as valid.

            Data Source=http:\\myserver\get.csv;"

            J Offline
            J Offline
            jphuphilly
            wrote on last edited by
            #5

            The address works fine, I can click the link no problem but when I try to get the datasource using the following code, it doesn't work. Da Intern

            M 1 Reply Last reply
            0
            • J jphuphilly

              The address works fine, I can click the link no problem but when I try to get the datasource using the following code, it doesn't work. Da Intern

              M Offline
              M Offline
              Mike Ellison
              wrote on last edited by
              #6

              Your address may be okay when you click on it, but the OleDb Jet Provider is having a problem with it, according to the exception you posted. Are you sure you can use a URL for the Data Source property in the connection string? If so, does your URL need to use forward slashes instead of backward slashes?

              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