• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Getting the text from file upload control to insert into a database

I'm getting this error when trying to get the name of a file to upload then insert the text into a table in my db.

Error: String or binary data would be truncated. Cannot insert the value NULL into column 'imgID'

i want to get the name of the files from these two file upload controls.

cmd.Parameters.AddWithValue("@img1", FileUpload1.ToString)
cmd.Parameters.AddWithValue("@img2", FileUpload2.ToString)
0
nickrjsmith
Asked:
nickrjsmith
  • 3
1 Solution
 
whityumCommented:
fuAddContacts.FileName.ToString()
0
 
whityumCommented:
oops, pasted from my own code, yours would be:
FileUpload1.FileName.ToString()
0
 
whityumCommented:
so combined:
cmd.Parameters.AddWithValue("@img1", FileUpload1.FileName.ToString())
cmd.Parameters.AddWithValue("@img2", FileUpload2.FileName.ToString())
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now