Solved

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

Posted on 2010-09-15
3
269 Views
Last Modified: 2012-05-10
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
Comment
Question by:nickrjsmith
  • 3
3 Comments
 
LVL 7

Accepted Solution

by:
whityum earned 500 total points
ID: 33685649
fuAddContacts.FileName.ToString()
0
 
LVL 7

Expert Comment

by:whityum
ID: 33685655
oops, pasted from my own code, yours would be:
FileUpload1.FileName.ToString()
0
 
LVL 7

Expert Comment

by:whityum
ID: 33685660
so combined:
cmd.Parameters.AddWithValue("@img1", FileUpload1.FileName.ToString())
cmd.Parameters.AddWithValue("@img2", FileUpload2.FileName.ToString())
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now