Help Me PLZZZZZZZZZZZZZZZZZZ

1277
1
06-21-2011 03:20 PM
MennaSoliman
New Contributor
Hi everybody!
I want to make a connection on my geodatabase to make command for  selecting  a specific table
to view it in dataGridView
but i have an error i couldn't fix it
anyone can help me
Code
C#
/ /connect to the database
            string conString =
               @"Provider=Microsoft.JET.OLEDB.4.0;"
               +@"data source=path.gdb";
            OleDbConnection conn = new OleDbConnection(conString);
            conn.Open();
            OleDbCommand command = new OleDbCommand();
            command = conn.CreateCommand();
            DataSet ds = new DataSet();
            conn.Open();
            command.CommandText = "SELECT * FROM PrimaryCircuit";
            OleDbDataAdapter adapter = new OleDbDataAdapter(command);
            adapter.Fill(ds);
            dataGridView1.DataSource = ds;


Error :the Microsoft Jet database engine cannot open the file 'path.gdb'.  It is already opened exclusively by another user, or you need permission to view its data.
0 Kudos
1 Reply
SandhyaYamarthi
New Contributor
Hi everybody!  
I want to make a connection on my geodatabase to make command for selecting a specific table 
to view it in dataGridView  
but i have an error i couldn't fix it  
anyone can help me  
Code  
C# 
/ /connect to the database 
string conString = 
@"Provider=Microsoft.JET.OLEDB.4.0;" 
+@"data source=path.gdb"; 
OleDbConnection conn = new OleDbConnection(conString); 
   conn.Open();
OleDbCommand command = new OleDbCommand(); 
command = conn.CreateCommand(); 
DataSet ds = new DataSet(); 
   conn.Open();
command.CommandText = "SELECT * FROM PrimaryCircuit"; 
OleDbDataAdapter adapter = new OleDbDataAdapter(command); 
adapter.Fill(ds); 
dataGridView1.DataSource = ds; 


Error :the Microsoft Jet database engine cannot open the file 'path.gdb'. It is already opened exclusively by another user, or you need permission to view its data.


Did you check that you have opened the connection twice? I think it causes the error due to schema lock on the database.
0 Kudos