[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Restricted data type attribute violation

daniel kurtz

10/6/2005 2:25:00 PM

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.

Thanks.

daniel



4 Answers

Paul Clement

10/7/2005 5:34:00 PM

0

On Thu, 6 Oct 2005 09:25:11 -0500, "daniel kurtz" <dkurtz@ameritech.net> wrote:

&#164; I''m trying to write data to an Access database via the ODBC Access driver.
&#164; The code looks like:
&#164;
&#164; strSQL = "INSERT INTO TargetTable (Field1, Field2, " _
&#164; & "Field3, Field4, Field5, Field6, " _
&#164; & "Field7, Field8, Field9, Field10, Field11) " _
&#164; & "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
&#164;
&#164; daTargetTable..InsertCommand.Connection = OdbcConnection1
&#164; daTargetTable..InsertCommand.CommandText = strSQL
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field1", OdbcType.Bit, 1, "Field1")
&#164; daTargetTable.InsertCommand.Parameters.Add( _
&#164; "@Field2", OdbcType.VarChar, 50, "Field2")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field3", OdbcType.VarChar, 50, "Field3")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field4", OdbcType.SmallInt, 1, "Field4")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field5", OdbcType.SmallInt, 2, "Field5")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field6", OdbcType.SmallInt, 4, "Field6")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field7", OdbcType.SmallInt, 2, "Field7")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field8", OdbcType.Int, 4, "Field8")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field9", OdbcType.VarChar, 4, "Field9")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field10", OdbcType.Bit, 1, "Field10")
&#164; daTargetTable..InsertCommand.Parameters.Add( _
&#164; "@Field11", OdbcType.Bit, 1, "Field11")
&#164;
&#164; daTargetTable..InsertCommand.Connection.Open()
&#164; daTargetTable..InsertCommand.ExecuteNonQuery()
&#164; daTargetTable..InsertCommand.Connection.Close()
&#164; The executenonquery command results in:
&#164;
&#164; ERROR [07006] [Microsoft][ODBC Microsoft Access Driver]Restricted data type
&#164; attribute violation
&#164;
&#164; I can''t find any info on what this error really means. I''ve been guessing it
&#164; is perhaps some kind of casting problem, but I''ve checked all the types
&#164; against everything listed for both ODBC and Access and can''t see what field
&#164; could be causing the problem. The error page doesn''t provide any more
&#164; information that the message above. Any suggestions? I''ve been getting
&#164; nowhere for almost two days now.
&#164;

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)

daniel kurtz

10/7/2005 6:07:00 PM

0

"Paul Clement" <UseAdddressAtEndofMessage@swspectrum.com> wrote in message
news:37cdk15qtd8u8jjnqtei4uc2bhtcg74mr5@4ax.com...
> 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.

I''m with you there. I''ve proven already that OLEDB does work for us in this
instance. Unfortunately, the requirement for ODBC was dictated by our
hosting service, according to my predecessor on the project. I''m trying to
dertermine how and why that is or was the case.

ddk


Paul Clement

10/11/2005 2:14:00 PM

0

On Fri, 7 Oct 2005 13:06:55 -0500, "daniel kurtz" <dkurtz@ameritech.net> wrote:

&#164; "Paul Clement" <UseAdddressAtEndofMessage@swspectrum.com> wrote in message
&#164; news:37cdk15qtd8u8jjnqtei4uc2bhtcg74mr5@4ax.com...
&#164; > I''m not very familiar with the ODBC data types, primarily because I don''t
&#164; > use nor recommend the use
&#164; > the MS Access driver. Instead I would highly recommend you use the Jet
&#164; > OLEDB provider since it is
&#164; > both more stable and supports more features than the Microsoft Access ODBC
&#164; > driver.
&#164;
&#164; I''m with you there. I''ve proven already that OLEDB does work for us in this
&#164; instance. Unfortunately, the requirement for ODBC was dictated by our
&#164; hosting service, according to my predecessor on the project. I''m trying to
&#164; dertermine how and why that is or was the case.

Ouch. Well if they''ve dictated ODBC then they''re a bit behind the times. I wouldn''t consider this
type of support even the slightest bit acceptable from a hosting service.


Paul
~~~~
Microsoft MVP (Visual Basic)

Matt Neerincx [MSFT]

10/14/2005 4:47:00 AM

0

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:
>
> &#164; I''m trying to write data to an Access database via the ODBC Access
> driver.
> &#164; The code looks like:
> &#164;
> &#164; strSQL = "INSERT INTO TargetTable (Field1, Field2, " _
> &#164; & "Field3, Field4, Field5, Field6, " _
> &#164; & "Field7, Field8, Field9, Field10, Field11) " _
> &#164; & "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
> &#164;
> &#164; daTargetTable..InsertCommand.Connection = OdbcConnection1
> &#164; daTargetTable..InsertCommand.CommandText = strSQL
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field1", OdbcType.Bit, 1, "Field1")
> &#164; daTargetTable.InsertCommand.Parameters.Add( _
> &#164; "@Field2", OdbcType.VarChar, 50, "Field2")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field3", OdbcType.VarChar, 50, "Field3")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field4", OdbcType.SmallInt, 1, "Field4")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field5", OdbcType.SmallInt, 2, "Field5")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field6", OdbcType.SmallInt, 4, "Field6")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field7", OdbcType.SmallInt, 2, "Field7")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field8", OdbcType.Int, 4, "Field8")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field9", OdbcType.VarChar, 4, "Field9")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field10", OdbcType.Bit, 1, "Field10")
> &#164; daTargetTable..InsertCommand.Parameters.Add( _
> &#164; "@Field11", OdbcType.Bit, 1, "Field11")
> &#164;
> &#164; daTargetTable..InsertCommand.Connection.Open()
> &#164; daTargetTable..InsertCommand.ExecuteNonQuery()
> &#164; daTargetTable..InsertCommand.Connection.Close()
> &#164; The executenonquery command results in:
> &#164;
> &#164; ERROR [07006] [Microsoft][ODBC Microsoft Access Driver]Restricted data
> type
> &#164; attribute violation
> &#164;
> &#164; I can''t find any info on what this error really means. I''ve been
> guessing it
> &#164; is perhaps some kind of casting problem, but I''ve checked all the types
> &#164; against everything listed for both ODBC and Access and can''t see what
> field
> &#164; could be causing the problem. The error page doesn''t provide any more
> &#164; information that the message above. Any suggestions? I''ve been getting
> &#164; nowhere for almost two days now.
> &#164;
>
> 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)