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
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