On 12/26/2012 11:19 AM, Carey Gagnon wrote:
First off let me start by saying that MsSQL is not my choice, and neither
is the table set up. I have to work with what I'm given.
That said, here goes:
I have a table with the following fields/structure from the bizobj file:
class ProvinceStateBizobj(dabo.biz.dBizobj):
def afterInit(self):
self.DataSource = "dbo.ProvinceState"
self.KeyField = "ProvinceState"
self.addField("ProvinceState")
self.addField("Country")
self.addFrom("dbo.ProvinceState")
# Setting the DataStructure explicitly here is optional, but
recommended as
# it will keep Dabo from interpreting field types from the backend
every
# time. It lets you specify what types you expect which fields to
be. Also,
# this information is used in self.setSQL() to add the fields to
the query.
# (field_alias, field_type, pk, table_name, field_name, field_scale)
self.DataStructure = (
("ProvinceState", "C", True, "dbo.ProvinceState",
"ProvinceState"),
("Country", "C", False, "dbo.ProvinceState", "Country"),
)
I do not like that the primary key is not an int and that it is also a
input field, but again, I have to work with what I was given.
When I do an insert from the python command line all goes well:
C:\src\ide>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit
(Intel)] onwin32
Type "help", "copyright", "credits" or "license" for more information.
import pymssql
con=pymssql.connect(host="somehost",user="someuser",password="somepassword",database="somedatabase")
cur=con.cursor()
cur.execute("INSERT INTO ProvinceState Values ('BC', 'Canada')")
con.commit()
con.close()
The insert is successful.
This is the only table that pymssql/Dabo pukes on. All the other tables
that have int as primary keys insert just fine.
On this particular table, even using the add record from an AppWizard app
of this table (keeping my programming out of the equation) throws the
following error:
ERROR - Error in scanRows of ?: (515, "Cannot insert the value NULL
into column 'ProvinceState', table 'NorProdV5.dbo.ProvinceState'; column
does not allow nulls. INSERT fails.DB-Lib error message 515, severity 16:\n
General SQL Server error: Check messages from the SQL Server
I'm not leaving the field null. I am adding the abbreviated province/state
I want to add in the provided AppWizard app textbox.
Anyone have an idea what's going on and what to do?
Please note, blowing up MsSQL server has been contemplated, but is not an
option.
Thanks in advance
Carey
Just before you do a bizObj.save() check the bizObj.CurrentSQL (either
use a print statement or a debug command) and that should tell you what
is wrong ( at least with the SQL statement). If the "ProvinceState" is
null find out why. You must be setting it somewhere.
Johnf
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]