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

New Topic/Question
Reply



MultiQuote




|