laled
9/28/2002 1:54:00 AM
You can help odbc.net choose the right type by setting the
OdbcType property of the OdbcParameter class yourself, ie:
model.OdbcType = OdbcType.NText;
Then everything should work correctly.
Thanks
Laled
This posting is provided "AS IS" with no warranties, and
confers no rights.
>-----Original Message-----
>I'm inserting rows in a MS Access database into the
following table using
>parameters:
>
>CREATE TABLE MODEL (
> F_MODEL_ID LONG NOT NULL,
> F_MODEL MEMO NOT NULL,
> CONSTRAINT PK_MODEL
> PRIMARY KEY (F_MODEL_ID)
>);
>
>I can only insert into "F_MODEL" strings with a length
between 1-255 or 2000
>and up.
>Any string with a length between 256 and 1999 throws the
following error:
>
>"ERROR [HY104] [Microsoft][ODBC Microsoft Access Driver]
Invalid precision
>value"
>
>It seems that the ODBC layer is assigning the wrong data
type for any length
>between 256 and 1999!
>
>The code is:
>==========================================================
==
>IDbDataParameter model = com.CreateParameter();
>model.DbType = DbType.String;
>model.Direction = ParameterDirection.Input;
>model.ParameterName = "model";
>
>string s = "";
>for (int i = 1; i <= 2000; i++) // 1-255 and 2000 and
up works fine
> s += "A";
>model.Size = s.Length;
>model.Value = s;
>
>com.Parameters.Add(model);
>com.CommandType = System.Data.CommandType.Text;
>
>sql = "INSERT INTO bs_model (f_model_id, f_model) VALUES
(" +
>this.ID.ToString() + ", ?)";
>com.CommandText = sql;
>
>com.ExecuteNonQuery(); // <<< ---- Error in this
line
>
>com.Parameters.Clear();
>==========================================================
==
>
>
>Is there a better way to insert memo fiels?
>
>Thanks.
>
>
>
>.
>