Inserting into Access Database from C# ASP.

G

Guest

The field is too small to accept the amount of data you attempted to add. Try
inserting or pasting less data. Is the error I get when it get
dbCmd.ExecuteNonQuery();. I have 15 fields to insert, therefore I did one
field at the time and found that the 13th field is the one causing the
problem, this field is in size 20 and data I am entering size is 1. I took
the INSERT command and entered it from Access Query and it worked, but not
from ASP page using C#. Please help I thank you for your assistance. I found
the similar error in
http://www.error-bank.com/microsoft.public.dotnet.languages.vb.1/196223_Thread.aspx. But there is no solutions posted.
 
H

Herfried K. Wagner [MVP]

Zak Milas said:
inserting or pasting less data. Is the error I get when it get
dbCmd.ExecuteNonQuery();. I have 15 fields to insert, therefore I did one
field at the time and found that the 13th field is the one causing the

Notice that there is a separate group for .NET+database questions available:

<URL:
 
W

W.G. Ryan eMVP

What does your update statement look like? Are you using Parameterized
query or dynamic SQL? You could have some illegal character if you're using
Dynamic SQL - that's the likely culprit.

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
Zak Milas said:
The field is too small to accept the amount of data you attempted to add. Try
inserting or pasting less data. Is the error I get when it get
dbCmd.ExecuteNonQuery();. I have 15 fields to insert, therefore I did one
field at the time and found that the 13th field is the one causing the
problem, this field is in size 20 and data I am entering size is 1. I took
the INSERT command and entered it from Access Query and it worked, but not
from ASP page using C#. Please help I thank you for your assistance. I found
the similar error in
http://www.error-bank.com/microsoft.public.dotnet.languages.vb.1/196223_Thread.aspx. But there is no solutions posted.
 
G

Guest

I am using Parameterized Query; dbCmd.Parameters.Add("@open_call",
OleDbType.VarChar, 1).Value = intOpenCall; Where open_call in Access is
Yes/No field. And intOpenCall = 1.
 
G

Greg Burns

If "open_call" is Yes/No field shouldn't you be using OleDbType.Boolean?

Why do you say "open_call" has a field length of 20, if it is a boolean
field?

dbCmd.Parameters.Add("@open_call", OleDbType.Boolean).Value =
CBool(intOpenCall)

Greg
 
M

Mike Labosh

I am using Parameterized Query; dbCmd.Parameters.Add("@open_call",
If "open_call" is Yes/No field shouldn't you be using OleDbType.Boolean?

Or possibly try setting it to -1. In Access, True = -1 and False = 0. If
the OP is thinking like a SQL Server BIT data type, he may be thinking 1 =
True, and Access will choke on that.
--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS!"
~~ General Barringer ~~
 
G

Guest

I have tried the -1 and this time I am getiing the error message:
(0x80040e57): Overflow
 
G

Greg Burns

Post your code.

Remember OleDb parameters are referenced by POSITION not by name.

For example

INSERT INTO mytable (call_desc, open_call) VALUES (@call_desc, @open_call)

cmd.parameters.add("@open_call", OleDbType.Boolean).value=bOpenCall
cmd.parameters.add("@call_desc", OleDbType.varchar,50).value=sDesc

This will fail.

Just my .02.

Greg
 
G

Guest

You'll have been nothing but simply fabulous. Yes! the problem was
order/position of the OleDB Parameters. I trully appretiate for your input in
helping me. After two days of sweat, its finally done. Thank you from the
bottom of my heart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top