Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access/SQL insert problem

Status
Not open for further replies.

Kenny62

Programmer
Mar 3, 2004
54
GB
Hi - i have a text field in a access DB which can accept text upto 255 chars (the max size of path+filename)
When i write to this field via VB code (INSERT ...statement) i get the following error message:

"Message=The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.Source: Microsoft JET Database Engine"

The string that i write is only 122 characters long - i don't understand what is going on here.
Can you explain:
I've tried trimming the string, Trim(mystring) - no difference.
I've tried truncating the string, Left(mystring,255) - no difference.

(Get a similar error if the DB is SQL - fundamental problem somewhere... :(
I should add that i'm using a dataset and the update method of data adapter :
The insert command of the da as follows:

' Create a custom Insert command.
Dim cmdInsert As New OleDbCommand("INSERT INTO tblTrackDetails (TrackName, Album, Artist, Genre, Composer, Comment, TrackLength, ReleaseYear, Created, Modified, Rating, BitRate, SampleRate, FileSize, FileLocation) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", m_DBConnect)
' Add arguments for the SET clause, that use the current field value.
With cmdInsert.Parameters.Add("@p1", GetType(String))
.SourceColumn = "TrackName"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p2", GetType(String))
.SourceColumn = "Album"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p3", GetType(String))
.SourceColumn = "Artist"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p4", GetType(String))
.SourceColumn = "Genre"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p5", GetType(String))
.SourceColumn = "Composer"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p6", GetType(String))
.SourceColumn = "Comment"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p7", GetType(String))
.SourceColumn = "TrackLength"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p8", GetType(Integer))
.SourceColumn = "ReleaseYear"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p9", GetType(Date))
.SourceColumn = "Created"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p10", GetType(Date))
.SourceColumn = "Modified"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p11", GetType(Integer))
.SourceColumn = "Rating"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p12", GetType(Integer))
.SourceColumn = "BitRate"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p13", GetType(Integer))
.SourceColumn = "SampleRate"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p14", GetType(Decimal))
.SourceColumn = "FileSize"
.SourceVersion = DataRowVersion.Current
End With
With cmdInsert.Parameters.Add("@p15", GetType(String))
.SourceColumn = "FileLocation"
.SourceVersion = DataRowVersion.Current
End With
m_DA.InsertCommand = cmdInsert

Thanks in advance:
Ken.
 
What datatype does the table that you are trying to update consist of? (e.g. what are the datatypes and lengths of the fields for your table tblTrackDetails?)
 
The field type is Text, its field size is 255.
Hope this info helps.
(I've tried a memo type - it makes no difference).
Ken.
 
Make sure your data is clean. For example, are there any embedded apostrophies?

It's possible that the error is raised by another field than the one you are looking at.

Dimandja
 
Thanks for the suggestion - i'll give it a try...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top