3 Replies - 281 Views - Last Post: 29 August 2012 - 02:35 AM Rate Topic: -----

#1 purvabhilare1587  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 27-May 12

Oledbexceptionunhandled not a valid file

Posted 29 August 2012 - 12:53 AM

Hi,

I am trying to search data from database.When I connect to the local database the search works absolutely fine but when I connect to the shared database it throws an exception saying not a valid file.The path is correct.I also checked other functions using the same path.Everything works properly but there's problem only with these few functions.My code is below.

   Private Sub Last7DaysButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Last7DaysButton.Click
        Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;Data Source=\\chhaya\Candidates.accdb;Jet OLEDB:Database Password=techno;"
        Dim sql As String

        WaitingDataGridView.Visible = False
        CloseButton.Visible = False
        SpeedLabel.Visible = False
        LowerLimitLabel.Visible = False
        LowerLimitTextBox.Visible = False
        UpperLimitLabel.Visible = False
        UpperLimitTextBox.Visible = False
        GoSpeedButton.Visible = False
        QualficationLabel.Visible = False
        QualificationComboBox.Visible = False
        GoButton.Visible = False
        WorkCenterLabel.Visible = False
        WorkCenterComboBox.Visible = False
        WorkCenterGoButton.Visible = False
        WorkCenterEmployedGoButton.Visible = False
        AreaLabel.Visible = False
        AreaTextBox.Visible = False

        GoAreaWaitingButton.Visible = False



        sql = "SELECT * FROM Infotable WHERE [Date] >= Date()-7 AND Remark LIKE 'waiting'"
        ' DataGridView1.Visible = True
        Dim connection As New OleDb.OleDbConnection(cs)

        Dim ds As New DataSet
        Dim da As New OleDb.OleDbDataAdapter
        ' Dim str As String

        'check if the record exists in the database
        'str = "Select * From Infotable Where LastName='" & LastNameTextBox.Text & "' AND FirstName='" & FirstNameTextBox.Text & "' AND MiddleName='" & MiddleNameTextBox.Text & "' "
        ds = New DataSet()
        da = New OleDb.OleDbDataAdapter(sql, connection)
        da.Fill(ds)

        'if record is found then display record
        If (ds.Tables(0).Rows.Count > 0) Then
            da = New OleDb.OleDbDataAdapter(sql, connection)
            ds = New DataSet()
            connection.Open()


            'make the datagridview visible
            WaitingDataGridView.Visible = True
            CloseButton.Visible = True
            '  WaitingDataGridView.Columns("ID").Visible = False


            WaitingDataGridView.ReadOnly = True

            ' DataGridView1CloseButton.Visible = True
            da.Fill(ds, "Infotable")
            connection.Close()
            WaitingDataGridView.DataSource = ds
            WaitingDataGridView.DataMember = "Infotable"
        Else
            'if the record is not found then display message
            MsgBox("Record Not Found")
        End If


    End Sub


Private Sub WorkCenterEmployedGoButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WorkCenterEmployedGoButton.Click

        Dim cs As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;Data Source=\\chhaya\Candidates.accdb;Jet OLEDB:Database Password=techno;"
        Dim sql As String



        sql = "SELECT * FROM Infotable WHERE WorkCenter = '" & WorkCenterComboBox.Text & "' and Remark LIKE 'employed' "
        ' da = New OleDb.OleDbDataAdapter(sql, connection)

        Dim connection As New OleDb.OleDbConnection(cs)

        Dim ds As New DataSet
        Dim da As New OleDb.OleDbDataAdapter
        ' Dim str As String

        'check if the record exists in the database
        'str = "Select * From Infotable Where LastName='" & LastNameTextBox.Text & "' AND FirstName='" & FirstNameTextBox.Text & "' AND MiddleName='" & MiddleNameTextBox.Text & "' "
        ds = New DataSet()
        da = New OleDb.OleDbDataAdapter(sql, connection)
        da.Fill(ds)

        'if record is found then display record
        If (ds.Tables(0).Rows.Count > 0) Then
            da = New OleDb.OleDbDataAdapter(sql, connection)
            ds = New DataSet()
            connection.Open()


            'make the datagridview visible
            WaitingDataGridView.Visible = True
            CloseButton.Visible = True
            '  WaitingDataGridView.Columns("ID").Visible = False


            WaitingDataGridView.ReadOnly = True

            ' DataGridView1CloseButton.Visible = True
            da.Fill(ds, "Infotable")
            connection.Close()
            WaitingDataGridView.DataSource = ds
            WaitingDataGridView.DataMember = "Infotable"
        Else
            'if the record is not found then display message
            MsgBox("Record Not Found")
        End If
       

    End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Oledbexceptionunhandled not a valid file

#2 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 463
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Oledbexceptionunhandled not a valid file

Posted 29 August 2012 - 01:40 AM

Hi,
At what line do you get the error?
Dim connection As New OleDb.OleDbConnection(cs)?

This post has been edited by raziel_: 29 August 2012 - 01:42 AM

Was This Post Helpful? 0
  • +
  • -

#3 purvabhilare1587  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 27-May 12

Re: Oledbexceptionunhandled not a valid file

Posted 29 August 2012 - 02:27 AM

View Postraziel_, on 29 August 2012 - 01:40 AM, said:

Hi,
At what line do you get the error?
Dim connection As New OleDb.OleDbConnection(cs)?



I get error at da.Fill(ds)
Was This Post Helpful? 0
  • +
  • -

#4 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 463
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: Oledbexceptionunhandled not a valid file

Posted 29 August 2012 - 02:35 AM

i dont see where you open the connection.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1