By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,571 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,571 IT Pros & Developers. It's quick & easy.

Reading tables using OleDBConnection

maylortaylor
P: 72
First off, i'm new to VB and this is my first project using OleDBConnection.

ok, so i'm trying to the most simple thing using oleDbConnection (i assume). I just want to read data from a table in the Access DB and display that information to dropboxes (or anything) in my winForm.

Expand|Select|Wrap|Line Numbers
  1. Public Class QueManger
  2. Dim dbConnection As OleDbConnection
  3. Dim dbCommand As OleDbCommand
  4. Dim dbDataAdapter As OleDbDataAdapter
  5. Dim ConnectString As String = "Provider = Microsoft.Jet.OLEDB.4.0;" & "Data Source = \\atrts10\F:\Applications\ATRTaxCert\Development\mtaylor\TaxCert_be_test.accdb"
  6. Dim dtMain As DataTable
  7.  
  8. Private Sub QueManger_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  9.  
  10.     StatusName()
  11. End Sub
  12.  
  13. Private Sub StatusName()
  14.     Dim taxconn As OleDbConnection
  15.     Try
  16.  
  17.         taxconn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\atrts10\F:\Applications\ATRTaxCert\Development\mtaylor\TaxCert_be_test.accdb")
  18.         Dim taxcmd As OleDbCommand = taxconn.CreateCommand
  19.         taxcmd.CommandText = "SELECT StatusName FROM Status ORDER BY StatusName"
  20.         Dim rdr2 As OleDbDataReader
  21.         If taxconn.State = ConnectionState.Closed Then
  22.             taxconn.Open()
  23.         End If
  24.         rdr2 = taxcmd.ExecuteReader
  25.  
  26.         'boxStatus.Items.Add("All")
  27.         While rdr2.Read()
  28.             boxClient.Items.Add(rdr2.Item("StatusName"))
  29.         End While
  30.     Catch ex As Exception
  31.  
  32.     Finally
  33.         taxconn.Close()
  34.     End Try
  35. End Sub
The error comes when it tries to run the "taxconn.Open()" function.

The error says "The Microsoft Access database engine cannot open or write to the file '\atrts10\F:\Applications\ATRTaxCert\Development\m taylor\TaxCert_be_test.accdb'. It is already opened exclusively by another user, or you need permission to view and write its data."

any thoughts?
Feb 25 '13 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,382
The message sounds fairly clear to me. Someone already has it open exclusively or you don't have the permissions to access that data.
Feb 26 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.