Filling Dataset from OleDBDataAdaptor - Unspecified Error

rvermeulen

Member
Joined
Apr 2, 2003
Messages
17
Location
New Jersey
Im trying to connect to an EMPLOYEES table in an XP Access DB. I was able to earlier connect to a different table and return data. However, when I try to create an OleDBDataAdapter and fill the Dataset to be used to bind to a datagrid, I get an: Unspecified Error: E_FAIL(0x8000405) exception.

Im not sure what Im doing wrong, seems pretty straightforward.
Here is the web.config file where I set my connection string:

<appSettings>
<add key="ConnectionString" value="Provider = Microsoft.jet.oledb.4.0;data source=c:\InetPub\wwwroot\ASPSample\ASPSample.mdb" />

Here is my code Im running in the Page_Load:
Code:
conn = New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("ConnectionString")

Dim SQL as string = "select UserID, FirstName, LastName, Address, City, State, ZipCode, HireDate, Position from EMPLOYEES"

Dim empDA as new OleDB.OleDbDataAdapter(SQL, conn)
Dim ds as new DataSet()

empDA.Fill (ds, "employees")
EmployeeGrid.DataSource = ds.Tables("employees").DefaultView
EmployeeGrid.DataBind()
The code fails on the Fill statement. Can anyone please help me. Im having trouble figuring this out.

Thanks in advance.
Rick
 
Last edited by a moderator:
try this...
Im assigning the conn string locally only for this test.
Code:
dim conn as string = "Provider = Microsoft.jet.oledb.4.0;" & _
           "data source=c:\InetPub\wwwroot\ASPSample\ASPSample.mdb" 

Dim SQL as string = "select UserID, FirstName, LastName, " & _
      "Address, City, State, ZipCode, HireDate, Position from EMPLOYEES"

Dim empDA as new OleDB.OleDbDataAdapter(SQL, conn)
Dim ds as new DataSet()

empDA.Fill(ds)
ds.Tables(0).TableName = "employees"
EmployeeGrid.DataSource = ds
EmployeeGrid.DataMember = "employees"
 
Robbie,
Im still getting the same error. However, check this out. I took one of your suggestions from a different forum and tried to drag the connection to the webform. The connection gets established and the test succeeds. However, when I go through the OleDbDataAdapter wizard, it fails to generate the SELECT statement when it uses the column names in the select statement. If I make the select statement, Select * from EMPLOYEES, it creates successfully. However, it wont stay like this, it keeps going back to the specific column names.

Do you know why it wants to do that?

Rick
 
SO this works? ... "Select * from EMPLOYEES"

and when you specify fields it doesnt?

If so, then you may have miss-spelled a field name.
 
Robby,

Thanks so much for all your help. Turns out that it chokes on the column Position. I switched it to Title instead and now I can select the individual columns I want and it works fine. I guess Position must be a keywork in Access?

Now that I have my data bound to the grid, how can I set the column widths so that the data doesnt wrap, etc. Do you have to do that programmatically, or can that be done at design time?

Thanks again.
Rick
 
Back
Top