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