Illegal attempt to use Text/Byte host variable - Inserting into TEXT column

Stuart.Sklinar

Trying to insert into a table (Text Column) via Dapper, and getting the error from Informix:

Illegal attempt to use Text/Byte host variable

I have written a small program to simulate this, and I am still up against problems.

We cannot currently use the Informix drivers, as they do not suit our needs.

using Dapper;
using System;
using System.Data.Odbc;
namespace DapperParamsTest
{
    class Program
    {
        static void Main(string[] args)
        {
            OdbcConnection conn = new System.Data.Odbc.OdbcConnection("Driver={IBM INFORMIX ODBC DRIVER (64-bit)}; Host=bylgia; Server=bylgia; Service=sqlexec; Protocol=onsoctcp; Database=DATABASE; Client_Locale=en_US.CP1252; DB_LOCALE=en_GB.1252");

            var dynParams = new DynamicParameters();

            dynParams.Add("np_c_ref",-1);
            dynParams.Add("np_np_type","T");
            dynParams.Add("np_text", System.Text.Encoding.Default.GetBytes("TEXT INPUT"), System.Data.DbType.Binary);

            conn.Execute("INSERT INTO notepads (np_c_ref, np_type,np_text) VALUES (?,?,?)",dynParams);

            Console.WriteLine("Written");
            Console.ReadLine();
        }
    }
}

Table Structure:

CREATE TABLE notepad
(
    np_c_ref int,
    np_type char(1),
    np_text TEXT
)
Marc Gravell

This question might actually be a lot simpler than my other answer presumes; I've just noticed you say the column is TEXT, yet you are passing it a byte[]. If you want that, you should probably be using the BYTE data type. If you want to use TEXT - just pass it the string (i.e. "TEXT INPUT") and forget about Encoding.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

inserting byte array into blob column

来自分类Dev

JQuery / Javascript - Combine text with variable for use as array index

来自分类Dev

PL/SQL Inserting into a table minus another table but inserting another column at the same time

来自分类Dev

How to reference host variable in Ansible template?

来自分类Dev

Add text to a value in a column

来自分类Dev

如何在 mongoDB 副本集中的 rs.add("host:port") 中使用 HOST VARIABLE

来自分类Dev

CL_MEM_ALLOC_HOST_PTR慢于CL_MEM_USE_HOST_PTR

来自分类Dev

如何使用通过`net use \\ host \ share`映射的Windows共享?

来自分类Dev

Use awk to find average of a column

来自分类Dev

How to use an exported variable in a makefile?

来自分类Dev

Add button + text in Infragistics ultragrid column

来自分类Dev

Sorting a numeric column in a text file with python

来自分类Dev

Column of text needs "summed" based on assigned value

来自分类Dev

Sublime Text 3中的plugin_host服务的目的是什么?

来自分类Dev

In SQL, is it possible to use a dummy column in an insert statement?

来自分类Dev

意外的令牌ILLEGAL与dragonallySetInnerHTML

来自分类Dev

Perl - is "uc" enable to use when return to a variable?

来自分类Dev

Can I use colons as variable names in Javascript?

来自分类Dev

Use of unassigned local variable on finally block

来自分类Dev

Use Greasemonkey to change Text to Images (on a static site)?

来自分类Dev

Sublime Text 3中消失的功能“ use”

来自分类Dev

Python CSV find string and pass column number to variable

来自分类Dev

Add hyperlink to text in a column generated by bootstrap-table

来自分类Dev

使用sqlite3_column_text()获取整数值

来自分类Dev

“ sqlite3_bind_text博士”和“ sqlite3_column_text先生”之谜

来自分类Dev

意外的令牌ILLEGAL Ajax发布

来自分类Dev

通过PHP生成的JavaScript ILLEGAL

来自分类Dev

When is upcasting illegal in C++?

来自分类Dev

.click()上的意外令牌ILLEGAL

Related 相关文章

  1. 1

    inserting byte array into blob column

  2. 2

    JQuery / Javascript - Combine text with variable for use as array index

  3. 3

    PL/SQL Inserting into a table minus another table but inserting another column at the same time

  4. 4

    How to reference host variable in Ansible template?

  5. 5

    Add text to a value in a column

  6. 6

    如何在 mongoDB 副本集中的 rs.add("host:port") 中使用 HOST VARIABLE

  7. 7

    CL_MEM_ALLOC_HOST_PTR慢于CL_MEM_USE_HOST_PTR

  8. 8

    如何使用通过`net use \\ host \ share`映射的Windows共享?

  9. 9

    Use awk to find average of a column

  10. 10

    How to use an exported variable in a makefile?

  11. 11

    Add button + text in Infragistics ultragrid column

  12. 12

    Sorting a numeric column in a text file with python

  13. 13

    Column of text needs "summed" based on assigned value

  14. 14

    Sublime Text 3中的plugin_host服务的目的是什么?

  15. 15

    In SQL, is it possible to use a dummy column in an insert statement?

  16. 16

    意外的令牌ILLEGAL与dragonallySetInnerHTML

  17. 17

    Perl - is "uc" enable to use when return to a variable?

  18. 18

    Can I use colons as variable names in Javascript?

  19. 19

    Use of unassigned local variable on finally block

  20. 20

    Use Greasemonkey to change Text to Images (on a static site)?

  21. 21

    Sublime Text 3中消失的功能“ use”

  22. 22

    Python CSV find string and pass column number to variable

  23. 23

    Add hyperlink to text in a column generated by bootstrap-table

  24. 24

    使用sqlite3_column_text()获取整数值

  25. 25

    “ sqlite3_bind_text博士”和“ sqlite3_column_text先生”之谜

  26. 26

    意外的令牌ILLEGAL Ajax发布

  27. 27

    通过PHP生成的JavaScript ILLEGAL

  28. 28

    When is upcasting illegal in C++?

  29. 29

    .click()上的意外令牌ILLEGAL

热门标签

归档