Cant Bind a data from a multi-table Inner Join using C#

G

Gareth Stretch

Hi Guys. i am using C#.net connecting to an Access database using
OleDbConnection i am using the following select Statement to join 3
tables

string strdvds = "SELECT dvd.name, category.description, dvd.zone,
dvd.price, dvd.booked_out, dvd.booked_out_date,(contacts.name +' '+
contacts.surname) as contact FROM (dvd LEFT JOIN category ON
dvd.category_id = category.id) LEFT JOIN contacts ON dvd.contact_id =
contacts.id ORDER BY dvd.name ASC";

the join works well if i run it in acess it returns all the records
correctly however when i fill the DataAdapter with the following code.
it gives me the following (see below the method)

public static DataSet ExecuteDataSet(string constring,CommandType cmd
, string selectString)
{
using (OleDbConnection DBCon = new OleDbConnection(constring))
{
DBCon.Open();
OleDbCommand DBcmd = new OleDbCommand(selectString,DBCon);
DBcmd.CommandType = cmd;
OleDbDataAdapter DA = new OleDbDataAdapter();
DA.SelectCommand = DBcmd;

DataSet DS = new DataSet();
DA.Fill(DS);

return DS;
}

}


********************ERROR *******************

IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr) at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS
dbParams, Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
behavior, Object& executeResult) at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method) at
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
behavior) at System.Data.Common.DbDataAdapter.FillFromCommand(Object
data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String
srcTable) at dvddetails.classes.DAL.ClsCon.ExecuteDataSet(String
constring, CommandType cmd, String selectString, String tablename) in
c:\inetpub\wwwroot\dvddetails\classes\dal\clscon.cs:line 65 at
dvddetails.classes.BLL.dvds.LoadDvds() in
c:\inetpub\wwwroot\dvddetails\classes\BLL\dvds.cs:line 90 at
dvddetails.Forms.addDvd.BindDvds() in
c:\inetpub\wwwroot\dvddetails\forms\frmddvd.aspx.cs:line 127

could some please tell me why this is happening. i dont understand the
error message. is the problem related to the multi-table join. all my
other grids work with sings table queries using the same
EXECUTEDATASET method.

Thanks in advance
Gareth Stretch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top