By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

Inserting into Access Database from C# ASP.

P: n/a
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....23_Thread.aspx. But there is no solutions posted.
Nov 21 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
"Zak Milas" <Za******@discussions.microsoft.com> schrieb:
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:news://news.microsoft.com/microsoft.public.dotnet.framework.adonet>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

P: n/a
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" <Za******@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
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....23_Thread.aspx. But there is no solutions posted.
Nov 21 '05 #3

P: n/a
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.

"W.G. Ryan eMVP" wrote:
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


Nov 21 '05 #4

P: n/a
> >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.
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 ~~
Nov 21 '05 #5

P: n/a
I have tried the -1 and this time I am getiing the error message:
(0x80040e57): Overflow

"Mike Labosh" wrote:
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.

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 ~~

Nov 21 '05 #6

P: n/a
Why use an integer to begin with? Why not use True and False?

Greg

"Mike Labosh" <ml*************@hotmail.com> wrote in message
news:uV****************@TK2MSFTNGP09.phx.gbl...
>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.

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 ~~

Nov 21 '05 #7

P: n/a
I have tried the true/false as well and I get similar error; (0x80040e57):
Overflow
"Greg Burns" wrote:
Why use an integer to begin with? Why not use True and False?

Greg

"Mike Labosh" <ml*************@hotmail.com> wrote in message
news:uV****************@TK2MSFTNGP09.phx.gbl...
>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.

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 ~~


Nov 21 '05 #8

P: n/a
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
"Zak Milas" <Za******@discussions.microsoft.com> wrote in message
news:4C**********************************@microsof t.com...
I have tried the true/false as well and I get similar error; (0x80040e57):
Overflow
"Greg Burns" wrote:
Why use an integer to begin with? Why not use True and False?

Greg

"Mike Labosh" <ml*************@hotmail.com> wrote in message
news:uV****************@TK2MSFTNGP09.phx.gbl...
>> >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.
>
>> 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 ~~
>
>


Nov 21 '05 #9

P: n/a
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.

"Greg Burns" wrote:
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


Nov 21 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.