Edit Record
Edit Record
johnw75
Posts: 13Questions: 2Answers: 0
Hi,
the problem is:
"SQLSTATE[22018]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value 'gruppe_id' to data type int."
Gruppe_ID is an int field on MS SQL Server 2008 table. When i try to update i get the error as follows.
The Edit is filled correctly as int but will be not correct send to DB.
What is wrong?
Thanks
This discussion has been closed.
Answers
Are you using Editor here or something else? If so, is this with the PHP or .NET libraries?
Allan
Hi,
i'm using latest Editor with PHP.
Can you show me your PHP configuration of Editor and also your MS SQL schema please?
Thanks,
Allan
Schema mssql;
liste.php
ATS_WEB_Gruppe_Tbl.php
```php
<?php
// DataTables PHP library and database connection
include ("../../../classes/Editor/DataTables.php");
// Alias Editor classes so they are easy to use
use DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
<?php > ``` ?>Editor::inst ( $db, 'ATS_WEB_Gruppe_Tbl', 'ID' )
->fields(
Field::inst( 'gruppe_id' )
->validator('Validate::notEmpty')
->getFormatter ( function ( $val, $data, $field ) {
return intval( $val ) ;
} )
->setFormatter ( function ( $val, $data, $field ) {
return $val ;
} ),
Field::inst( 'gruppe_text' )->validator( 'Validate::notEmpty' )
)
->process( $_POST )
->json();
i tried to change with set and getFormatter, Id is shown correctly with getFormatter as int in JSON. Edit Formular is correct field, but cannot save. Known error will be shown.
Thanks for help
config.php
Database connection work. I changed nothing.
Thanks
Thanks for the details. I'll take a look through them and get back to you tomorrow.
Regards,
Allan
Hi Allan,
fine thanks.
J
HI Allan,
any Progress?
J
Hi,
Apologies for the delay! I've just been looking into it, and haven't been able to reproduce the issue myself unfortunately. Can you check what version of PHP you are using? There are a few threads about this error in the early 5.3 series.
Are you using Windows or *nux? I'm going to guess Linux since it mentioned the ODBC driver - is that correct? What version of the ODBC driver are you using and how is it configured? (I must confess I always found ODBC on linux to be a bit of a nightmare :-) ).
Regards,
Allan
Hi,
thanks for your response. We are you using IIS 7.5 with web Platform manager installed php 5.5.34 on a windows Server 2012 with SQL Server 2008. We installed the Driver with the IIS Web Platform manager for PHP 5.5. Thats mean we need sqlserv_connect for connecting to the database etc. Could it be that the PDO Driver, with is part of Editor I think, works not fine?
Strange is that i changed all fields to varchar, but that interface ignored that.
Is it helpful for?
Regards J
If you are using a Windows server, could you try the Microsoft SQLServer PDO driver rather than the ODBC driver?
Editor doesn't provide PDO drivers, but rather it utilises those those for the various database types available.
Regards,
Allan
We are using Windows Server and these are excat the driver that we are using installed by Web Platform installer for IIS 7.5
We are not using ODBC Driver. Strange is that Edit Dialog will be filled with correct information, but cannot stored in DB with same values.
is the editor a trial version and not free, how can i see that, can that be a problem?
The trial version shouldn't make any difference here - the only difference between the trial and the licensed version is that the Javascript in the trial is obfuscated and time limited. That will have no effect on the server-side aspect here.
The reason I mention ODBC is the error message you mentioned back at the top of the thread:
Having said that, looking at the PHP documentation, it now looks like the MS SQLServer drivers (3.1 and 3.2) do actually require ODBC - which I don't think they did before - so we can possibly ignore that - sorry!
Let me see if I can update my PHP and get it running locally and I'll post back.
Allan
Hi Allan,
possible to reproduce?
Thanks
Apologies, I haven't had a chance to try and do so yet. I'll post back as soon as possible.
Allan