If (Radiobuttonlist1.SelectedItem.Value = 2) Then
Dim path As String
'path = upload.PostedFile.FileName
path = "D:\Karthi Scripts\XML CHK\shg_repayment.xls"
'Response.Write(path)
'Response.End()
Dim connect As String
connect = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source= '" + path + "'" + "Extended Properties='Excel 4.0;HDR=Yes;IMEX=1;'"
Dim conn As New OleDbConnection(connect)
conn.Open()
Dim ds = New DataSet()
Dim od As New OleDbCommand("SELECT * FROM [Sheet1$]", conn)
Dim orr As OleDbDataReader
grdView.DataSource = orr
grdView.DataBind()
conn.Close()
End If
The Above code i have used to read the excel file and view in the gridview.But i m getting the following error
Format of the initialization string does not conform to the OLE DB specification.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: Format of the initialization string does not conform to the OLE DB specification.
Source Error:
|
Thanks in advance
Satyapriya NayakPosted Dec 30, 2012, 12:57 AM
kasi viswanathanPosted Dec 30, 2012, 12:46 AM
kasi viswanathanPosted Dec 30, 2012, 12:35 AM
kasi viswanathanPosted Dec 30, 2012, 12:15 AM
Rajkumar RPosted Dec 15, 2011, 3:40 AM
Satyapriya NayakPosted Dec 14, 2011, 7:09 AM
This is a solution for windows application.
Imports System.Data.OleDb
Module Module1
Public con As OleDbConnection
Sub pintu(ByVal s As String)
con = New OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source='" & s & " '; " & "Extended Properties=Excel 8.0;")
End Sub
Public com As OleDbCommand
Public ds As DataSet
Public oledbda As OleDbDataAdapter
Public dt As DataTable
Public str As String
End Module
Imports System.Data.OleDb
Public Class Form1
Private Sub btnbrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbrowse.Click
Dim openfiledialog1 As New OpenFileDialog
openfiledialog1.ShowDialog()
openfiledialog1.Filter = "allfiles|*.xls"
TextBox1.Text = openfiledialog1.FileName
End Sub
Private Sub btndisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndisplay.Click
pintu(TextBox1.Text)
Try
con.Open()
str = "select * from [sheet1$]"
com = New OleDbCommand(str, con)
ds = New DataSet
oledbda = New OleDbDataAdapter(com)
oledbda.Fill(ds, "[sheet1$]")
con.Close()
DataGridView1.DataSource = ds
DataGridView1.DataMember = "[sheet1$]"
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
Thanks
Rajkumar RPosted Dec 14, 2011, 6:44 AM
VulpesPosted Dec 14, 2011, 6:38 AM