Matt Neerincx [MSFT]
10/14/2005 4:47:00 AM
I took a quick peek at the Jet ODBC driver source code.
What this error message means is you are passing in some value that cannot
be converted to the target field type.
So for example you try to store a varchar into a bit field or some other
nonsensical conversion.
So what you do is start small and create a table with a few fields, test
that you can insert into the basic fields, then keep adding types and
figuring out the best way to map them to ODBC types. Or you could look at
your insert and try tweaking around with different input types. I would
suspect the bit fields and smallint fields first.
--
Matt Neerincx [MSFT]
This posting is provided "AS IS", with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
"Paul Clement" <UseAdddressAtEndofMessage@swspectrum.com> wrote in message
news:37cdk15qtd8u8jjnqtei4uc2bhtcg74mr5@4ax.com...
> On Thu, 6 Oct 2005 09:25:11 -0500, "daniel kurtz" <dkurtz@ameritech.net>
> wrote:
>
> ¤ I''m trying to write data to an Access database via the ODBC Access
> driver.
> ¤ The code looks like:
> ¤
> ¤ strSQL = "INSERT INTO TargetTable (Field1, Field2, " _
> ¤ & "Field3, Field4, Field5, Field6, " _
> ¤ & "Field7, Field8, Field9, Field10, Field11) " _
> ¤ & "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
> ¤
> ¤ daTargetTable..InsertCommand.Connection = OdbcConnection1
> ¤ daTargetTable..InsertCommand.CommandText = strSQL
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field1", OdbcType.Bit, 1, "Field1")
> ¤ daTargetTable.InsertCommand.Parameters.Add( _
> ¤ "@Field2", OdbcType.VarChar, 50, "Field2")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field3", OdbcType.VarChar, 50, "Field3")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field4", OdbcType.SmallInt, 1, "Field4")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field5", OdbcType.SmallInt, 2, "Field5")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field6", OdbcType.SmallInt, 4, "Field6")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field7", OdbcType.SmallInt, 2, "Field7")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field8", OdbcType.Int, 4, "Field8")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field9", OdbcType.VarChar, 4, "Field9")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field10", OdbcType.Bit, 1, "Field10")
> ¤ daTargetTable..InsertCommand.Parameters.Add( _
> ¤ "@Field11", OdbcType.Bit, 1, "Field11")
> ¤
> ¤ daTargetTable..InsertCommand.Connection.Open()
> ¤ daTargetTable..InsertCommand.ExecuteNonQuery()
> ¤ daTargetTable..InsertCommand.Connection.Close()
> ¤ The executenonquery command results in:
> ¤
> ¤ ERROR [07006] [Microsoft][ODBC Microsoft Access Driver]Restricted data
> type
> ¤ attribute violation
> ¤
> ¤ I can''t find any info on what this error really means. I''ve been
> guessing it
> ¤ is perhaps some kind of casting problem, but I''ve checked all the types
> ¤ against everything listed for both ODBC and Access and can''t see what
> field
> ¤ could be causing the problem. The error page doesn''t provide any more
> ¤ information that the message above. Any suggestions? I''ve been getting
> ¤ nowhere for almost two days now.
> ¤
>
> I''m not very familiar with the ODBC data types, primarily because I don''t
> use nor recommend the use
> the MS Access driver. Instead I would highly recommend you use the Jet
> OLEDB provider since it is
> both more stable and supports more features than the Microsoft Access ODBC
> driver.
>
>
> Paul
> ~~~~
> Microsoft MVP (Visual Basic)