StrataFrame Forum

FillByPrimaryKey problem

http://forum.strataframe.net/Topic6430.aspx

By Joseph-Carl Theodat - 1/30/2007

Hi,

My BO is well configured and the DB ids fine. I want to add a custom fill method :

public void FillAllByID( int user)

{

      FillByPrimaryKey(user);

}

I'm having a SqlException saying " Invalid object name .." with the name of the table. The table name is good. Since the framework take care of the connection, am I missing something?

By Ben Kim - 1/30/2007

Did you try:

Me.FillByPrimaryKey(User)?

Ben

By Greg McGuffey - 1/30/2007

I think in C## it would be:



this.FillByPrimaryKey(user);


By Greg McGuffey - 1/30/2007

Have you tried to just calling FillByPrimaryKey(user) from code (not in the BO, but from some other code)? Do you get the exception then?
By Joseph-Carl Theodat - 1/30/2007

It's a typo mistake ... in my code it's written this.FillByPrimaryKey(user)

I am still having the SqlException "invalid object name with TABLENAME"

 

By Joseph-Carl Theodat - 1/30/2007

I tried already ...(calling from the code,  not BO) ... no success
By Greg McGuffey - 1/30/2007

As you mentioned, this "should" work. Did you turn on SQL debugging to see exactly what SQL was being generated? That often help you the error.



In AppMain.cs (or whatever is the main app file in C#), at the bottom of the SetDataSources() method, add this:



DataBasics.DataSources("").SetDebugOn("c:\Debug.html",True);



For more info, see the last post on this page:



http://forum.strataframe.net/Topic3442-6-2.aspx?Highlight=SetDebugOn


By Trent L. Taylor - 1/30/2007

Setting the Debug on is always a good idea when you run into something like this.  When you are using the intrinsic methods, there are some assumptions made by the framework.  In the case of the FillByPrimaryKey, we assume that a primary key has been defined on the BO, for example.

As a side note, there is really no need to create a method to call the intrinsic method.  You can direcly call the FillByPrimaryKey and pass it the PK value.  If you are going to create a custom method, then you might go ahead and call the FillDataTable method and see if you are having the same problems.

I recommend using an SQLDbCommand and parameterized queries, but just for testing purposes, you can just pass a SELECT statement as well.

this.FillDataTable("SELECT * FROM MyTable WHERE MyPk=123");

See if you get the same response in this scenario.  But definitely go through the debug mode as well so we can see what the problem is that you are running into.

Note: Just as a side note, you do not have to provide the pre-qualifying location in .NET (Me or this).  If you call the FillByPrimaryKey method it is the same as calling this.FillByPrimeryKey.

By Joseph-Carl Theodat - 1/30/2007

Hi,

I tried before a SQL  Fill data table and the same result. I know how to make a basic sql statement and there is somehow there is something wrong ... 

What I did:

1- Add BO to the project

2- Use the BO mapper to configure my project and the BO , build ok

3- Rebuild the solution

4- Drop the BO object on my form

5- Tried several times the fill FillDataTable with SQL string (same error)

The thing is that my SF DB in on server A and my testing DB in on server B. Both connection were created with the Connection Wizard. But, the SqlException shows server A eventhough the BO was created with server B. I think the answer comes from there ... Any idea?

Note:

I add 'this' only the guys who replied for my question BigGrin

By Joseph-Carl Theodat - 1/30/2007

I reset my desktop and it work... Anyway.. thanks guys...!!

Have a good one

By Trent L. Taylor - 1/30/2007

Glad you got it going Smile