Thank you for your article on Tcl Database connectivity interface. I wnder if you could help us. We had to switch to x64 bit process and as we did our MS SQL queries stopped working. That's because we were using Tclodbc library and it looks like there is no x64 bit version.
We started looking at alternatives and tried tdbc but we are having problems with character fields passed as parameters. I created a test table with 2 integer columns, 2 varchar columns (50 and 100 long).
I am trying to insert records and the following happens:
1. If I insert records providing only 2 integer parameters everything works fine - 5 records get inserted.
2. If I insert records providing only 1 character parameter 1 record gets inserted and then the script fails with the following error: "[Microsoft][ODBC Driver 11 for SQL Server]String data, right truncation"
3. If I am trying to pass two character parameters or an integer parameter and a character parameter the nothing gets inserted - I just receive the same error as above.
I didn't test any other data types but it looks like something is wromg with character parameters (I alos tried nvarchar and char columns).
Here is my code:
package require tdbc::odbc
set con "Driver={ODBC Driver 11 for SQL Server};server=server;database=database;Intergrated Security=True;Trusted_Connection=Yes"
tdbc::odbc::connection create db $con
Thank you for your article on Tcl Database connectivity interface. I wnder if you could help us. We had to switch to x64 bit process and as we did our MS SQL queries stopped working. That's because we were using Tclodbc library and it looks like there is no x64 bit version.
We started looking at alternatives and tried tdbc but we are having problems with character fields passed as parameters. I created a test table with 2 integer columns, 2 varchar columns (50 and 100 long).
I am trying to insert records and the following happens:
1. If I insert records providing only 2 integer parameters everything works fine - 5 records get inserted.
2. If I insert records providing only 1 character parameter 1 record gets inserted and then the script fails with the following error: "[Microsoft][ODBC Driver 11 for SQL Server]String data, right truncation"
3. If I am trying to pass two character parameters or an integer parameter and a character parameter the nothing gets inserted - I just receive the same error as above.
I didn't test any other data types but it looks like something is wromg with character parameters (I alos tried nvarchar and char columns).
Here is my code:
package require tdbc::odbc
set con "Driver={ODBC Driver 11 for SQL Server};server=server;database=database;Intergrated Security=True;Trusted_Connection=Yes"
tdbc::odbc::connection create db $con
set insert_cmd [db prepare {INSERT INTO dbo.testing_tdbc (f50,f100) VALUES(:f50,:f100) } ]
$insert_cmd paramtype f50 char 50
$insert_cmd paramtype f100 char 100
foreach fint [list 1 2 3 4 5] {
set fi1 $fint
set fi2 [expr {$fi1*2}]
set f50 "${fi2}_${fi1}"
set f100 $f50
}
$insert_cmd close
db close
I tried the same with ODBC Driver 13 for SQL Server - all with the same result.
Any help will be appreciated.
Thanks,
Sergey