Column XXX does not belong to table YYY

Data Access Application Blocks Forum

Column XXX does not belong to table YYY

Postby vearl on Wed May 28, 2008 2:21 am

I am running into a problem when I try to access a column from my table.
Example.. I have tblCustomers. I have column password, varchar(20).

In the code when I try to access it Cust.s_Password = \"whatever\" I get an exception. Column 'Password' does not belong to table tblCustomers.

Here is the call stack:

[ArgumentException: Column 'Password' does not belong to table tblCustomers.]
System.Data.DataRow.set_Item(String columnName, Object value)
NCI.EasyObjects.EasyObject.SetColumnNull(String fieldName)
NDIWeb._tblCustomers.set_s_Password(String Value)

I do have the column in the concrete class and the business class.

Any Ideas? Thanks
vearl
Lurker
 
Posts: 7
Joined: Tue Nov 13, 2007 12:58 am

Postby mgnoonan on Thu May 29, 2008 5:45 pm

Are you loading all the columns when you do Query.Load()? For example, do you have any calls to Query.AddResultColumn()?

See below:

Code: Select all
// Using a Northwind example
Employees emp = new Employees();

// SELECT columns
emp.Query.AddResultColumn(EmployeesSchema.EmployeeID);
emp.Query.AddResultColumn(EmployeesSchema.FirstName);
emp.Query.AddResultColumn(EmployeesSchema.LastName);

// WHERE clause
emp.Where.EmployeeID.Value = 1;

// Generates SELECT [EmployeeID], [FirstName], [LastName] FROM [dbo].[Employees]
emp.Query.Load();

// Generates an exception because [City] was not in the SELECT clause
emp.s_City = \"Dayton\";


EasyObjects does not do any comparison of the SELECT clause and the Schema of the object. It basically just takes the results of the query and loads them into the object. In fact, you can load the object using any SELECT query, including from a different source table than the object was generated from!

But if you don't do \"SELECT *\" from the original table, you can't set all the column values using the generated properties, and you can't do a Save(), because the object is expecting all of the original table columns to be present in the object.

It's been a long-standing enhancement request to do dynamic saves (i.e. only the columns and values that have changed), but I don't have a delivery date for that feature.
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH

Postby vearl on Sat May 31, 2008 11:30 pm

Do I need to load all the columns?
Here is what I had. I two columns and the one that wasnt found was in the addResultColumns function.

Customers.Query.AddResultColumn(NdiWeb_.tblCustomersSchema.EmailAddress);
Customers.Query.AddResultColumn(ndiWeb_.tblCustomersSchema.Password);
Customers.Where.EmailAddress.Operator:=WhereParameter.Operand.Equal;
Customers.Where.EmailAddress.Value:=Email;
Customers.Where.EmailAddress.Conjunction:=Whereparameter.Conj.⩓
Customers.Where.Password.&Operator:=WhereParameter.Operand.Equal;
Customers.Where.password.Value:=Password;

if Customers.Query.Load then

Also looking through the profiler I only see
this being sent.
-- 'password' was found in the text of this event.
-- The text has been replaced with this comment for security reasons.
but the query.lastquery returns SELECT * FROM [dbo].[tblCustomers] WHERE [EmailAddress] = @EmailAddress AND [Password] = @Password
There is not actual select statement being sent. Maybe I am doing something wrong.

I also have set Customers.DefaultCommandType:=Commandtype.Text;
vearl
Lurker
 
Posts: 7
Joined: Tue Nov 13, 2007 12:58 am

Postby vearl on Sat May 31, 2008 11:55 pm

Actually my problem now has become that the actual select statement is not being sent to sql.

Just this:

-- 'password' was found in the text of this event.
-- The text has been replaced with this comment for security reasons.

I have not idea whats going on I may have two seperate issues. I am trying to fix this one first now. Any idea why this would happen?

Thanks
vearl
Lurker
 
Posts: 7
Joined: Tue Nov 13, 2007 12:58 am

Postby mgnoonan on Sat Jun 21, 2008 2:54 pm

That's kind of weird, can you send me some code I can take a look at?
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH


Return to EasyObjects.NET (Microsoft Enterprise Library)

Who is online

Users browsing this forum: No registered users and 1 guest