PC Review


Reply
Thread Tools Rate Thread

C# Access 2000 file error.

 
 
sevenso
Guest
Posts: n/a
 
      16th Jul 2003
I am having problems coding to an Access database (2000
format). I am using the Microsoft Development Enviroment
2003 and 1.1 .Net Framework.

Here is the code that I am trying:
string strConnect =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\CSharp\Receipt\Test.MDB" ;
string strSQL = "SELECT * FROM Names";

try
{

OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL,
strConnect);


DataSet ds = new DataSet("Names");
adapter.Fill(ds, "Names"); // never gets beyond here

string str = (string)ds.Tables["Names"].Rows[0]
["FirstName"];

DataRow newRow = ds.Tables["Names"].NewRow();
newRow["FirstName"] = "Teddy";
ds.Tables["Names"].Rows.Add(newRow);
ds.Tables["Names"].AcceptChanges();

}
catch (System.Data.OleDb.OleDbException ex)
{
MessageBox.Show(ex.Message);
Debug.WriteLine(ex.Message);
}

When this runs an exception is thrown at adapter.Fill
(...).
The message is: "IErrorInfo.GetDescription failed with
E_FAIL(0x80004005)."

I also can't open the database in the Data Connections
area of the IDE. I get an Unkown error message box.

Thanks for the help.


 
Reply With Quote
 
 
 
 
sevenso
Guest
Posts: n/a
 
      16th Jul 2003
Paul, thanks for the input. I have tried putting the
double slashes in and the result is the same. Any other
ideas?

>-----Original Message-----
>On Tue, 15 Jul 2003 22:26:19 -0700, "sevenso"

<(E-Mail Removed)> wrote:
>
>¤ I am having problems coding to an Access database

(2000
>¤ format). I am using the Microsoft Development

Enviroment
>¤ 2003 and 1.1 .Net Framework.

>¤ Here is the code that I am trying:
>¤ string strConnect =
>¤ @"Provider=Microsoft.Jet.OLEDB.4.0;Data
>¤ Source=D:\CSharp\Receipt\Test.MDB" ;
>¤ string strSQL = "SELECT * FROM Names";

>
>In C# your file path must use double slashes instead of

a single slash:
>
>string ConnectionString;
>ConnectionString

= "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\\CSharp\Receipt\\Test.MDB";
>
>
>Paul ~~~ (E-Mail Removed)
>Microsoft MVP (Visual Basic)
>.
>

 
Reply With Quote
 
Ron Allen
Guest
Posts: n/a
 
      16th Jul 2003
Do you have read/write permissions in the D:\Csharp\Receipt directory? You
would need this to open the database. Also have you opened the database
directly with Access? You may want to do a Compact/Repair on the database
if you have Access installed.

Ron Allen
"sevenso" <(E-Mail Removed)> wrote in message
news:08e501c34b5a$c99a2c50$(E-Mail Removed)...
> I am having problems coding to an Access database (2000
> format). I am using the Microsoft Development Enviroment
> 2003 and 1.1 .Net Framework.
>
> Here is the code that I am trying:
> string strConnect =
> @"Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=D:\CSharp\Receipt\Test.MDB" ;
> string strSQL = "SELECT * FROM Names";
>
> try
> {
>
> OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL,
> strConnect);
>
>
> DataSet ds = new DataSet("Names");
> adapter.Fill(ds, "Names"); // never gets beyond here
>
> string str = (string)ds.Tables["Names"].Rows[0]
> ["FirstName"];
>
> DataRow newRow = ds.Tables["Names"].NewRow();
> newRow["FirstName"] = "Teddy";
> ds.Tables["Names"].Rows.Add(newRow);
> ds.Tables["Names"].AcceptChanges();
>
> }
> catch (System.Data.OleDb.OleDbException ex)
> {
> MessageBox.Show(ex.Message);
> Debug.WriteLine(ex.Message);
> }
>
> When this runs an exception is thrown at adapter.Fill
> (...).
> The message is: "IErrorInfo.GetDescription failed with
> E_FAIL(0x80004005)."
>
> I also can't open the database in the Data Connections
> area of the IDE. I get an Unkown error message box.
>
> Thanks for the help.
>
>



 
Reply With Quote
 
Paul Clement
Guest
Posts: n/a
 
      16th Jul 2003
On Wed, 16 Jul 2003 06:43:39 -0700, "sevenso" <(E-Mail Removed)> wrote:

¤ Paul, thanks for the input. I have tried putting the
¤ double slashes in and the result is the same. Any other
¤ ideas?

Actually yes I do. Try enclosing the Names table with brackets - it is an ODBC reserved word:

string strSQL = "SELECT * FROM [Names]";


Paul ~~~ (E-Mail Removed)
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2000 Could not use 'Admin'; file already in use. (Error 304 CAM Windows Vista General Discussion 0 23rd Dec 2007 09:13 PM
access file error in Windows Xp and 2000 Jo D Windows XP General 3 24th Mar 2004 08:51 AM
Access 2000 Could not lock file Error Message Sandy Microsoft Access 1 18th Mar 2004 07:59 PM
Access 2000 Swithboard Manager-path/file access error Barry Microsoft Access 0 8th Jan 2004 12:36 PM
Error trying to link an excel and/or text file in Access 2000 Erdal Guvenc Microsoft Access External Data 0 18th Sep 2003 06:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 PM.