I'm new to WC and using 6.10. Trying to use wwBusiness Object Builder to point to a SQL Server table. I'm getting the message, "Invalid column name 'pkfield'. [1526:207]". I am able to successfully use the "Create SQL Server Tables" wizard and verified the "ww" tables exists, so connection is not the issue.
Base table to map class to: Client
ID Table: wws_id
PK Field: clientid
Fox Data: unchecked
SQL Data: checked
SQL Connection String including database: same as used in project INI file.
The clientID field is INT.
Other tables in the database are under schemas, i.e. SysAdmin.Projects, CostPlan.Entities. Will Web Connection be able to handle tables under a schema? Thanks.
Hi Joe,
What are you doing when this error occurs? Inserting? Updating? A code snippet would help pin this down a little better.
PkField
is the variable that determines the name of the pk field that is to be updated via wwBusiness. It should be a parameter name not a field name in the actual sql query. Can you also check the cSql
property after the call that fails and see what the actual executing SQL looks like.
Also I think if you want to use the samples Customers
table your pkField is Id
not CustId
.
FWIW you can always test without even creating a business object subclass with code like this:
loCustomer = CREATEOBJECT("wwBusiness")
loCustomer.nDataMode = 2
loCustomer.cConnectstring = "database=webstore"
loCustomer.cFilename = "wws_customers"
loCustomer.cPkfield = "pk"
? loCustomer.query("select * from wws_customers")
? loCustomer.Load(3)
? loCustomer.oData.Updated
loCustomer.oData.Updated = DATE()
? loCustomer.Save()
? loCustomer.cErrorMsg
+++ Rick ---
Rick,
I get the message when I click the Create button in the wwBusiness Object Builder, so no code to share. After reading more into the subject and looked at other examples, I manually subclassed wwBusiness and filled in the properties. Thanks.
Rick,
The error was due to the wws_id table structure in SQL Server. It only contained 2 fields: tablename and ID. The error was coming from this code in GenerateBusObject method:
*** If it doesn't exist create it!
IF RECCOUNT() < 1
lnResult = loSQL.Execute([INSERT INTO ] + lcIDAlias + [ (tablename, id, pkfield, pkfieldtyp, pkwidth) VALUES ('] + ;
lcTable + [',0,'pk','I',4)])
IF lnResult # 1
THIS.cErrorMsg = loSQL.cErrorMsg
THIS.lError = .T.
RETURN .F.
ENDIF
ENDIF
Found the full/correct table structure and recreated the table. It has 'pk' hard coded for the pkfield. This this correct?
Also, in the GenerateBusObject method, JustStem() was dropping the table name due to the schema prefix, 'SysAdmin.AppUser'. I had to trick the code by adding a fake extension, 'SysAdmin.AppUser.xxx', in the wwBusiness Object Builder wizard.
Considering the code it generated is minimal, it'll be easy to move forward and manually do it for the rest. Thanks.