Weird exception with OLEDB Parameter Insert
Posted
by
Seamus MacKenzie
on Stack Overflow
See other posts from Stack Overflow
or by Seamus MacKenzie
Published on 2012-07-01T23:51:07Z
Indexed on
2012/07/02
3:16 UTC
Read the original article
Hit count: 194
Getting a strange error when trying to insert data into an Access database using parameters. the line where I am getting a problem is :-
thisCommand.CommandText = "INSERT INTO Events (Venue_ID, Date_Start, Date_End, Time_Start, Time_End, Name, Description, Event_Type, Buy_Tickets_URL) VALUES (@VenID, @DStart, @DEnd, @evTime, @evTime, @Name, @Des, @EvType, @SysUrl);";
string desc = GetDesc(rec.EvName);
thisCommand.Parameters.AddWithValue("@Des", desc);
thisCommand.ExecuteNonQuery();
None of the other parameters cause a problem but when trying to insert data to the description field I get a database exception saying the field is too small to accept the amount of data. The problem is my program is only trying to insert 3 characters when it throws the error and the Description field is a memo so should be able to hold up to 65000+ characters. When inserting a value manually in the CommandText everything works fine so it must be something to do with the parameter properties.
© Stack Overflow or respective owner