TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ToBe
NA
164
94.2k
Uploading multi images to SQL Server
May 29 2013 2:26 AM
Hi every one
I have this code included in my Save button to save image in the the Database.
it's working perfect. but i want to do it for 5 FileUpload Controller how can i do it ?
string cn_str = ConfigurationManager.ConnectionStrings["REGConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(cn_str);
con.Open();
SqlCommand cmd_sql = new SqlCommand("imageAdd", con);
cmd_sql.CommandType = CommandType.StoredProcedure;
string filePath = this.FileUpload1.PostedFile.FileName;
string filename = Path.GetFileName(filePath);
string ext = Path.GetExtension(filename);
Stream imgStream = FileUpload1.PostedFile.InputStream;
BinaryReader imgBinary = new BinaryReader(imgStream);
Byte[] bytes = imgBinary.ReadBytes((Int32)imgStream.Length);
imgBinary.Close();
imgStream.Close();
cmd_sql.Parameters.Add("@imgName", SqlDbType.Text).Value = filename;
cmd_sql.Parameters.Add("@imgType", SqlDbType.Text).Value = ext.ToString() ;
cmd_sql.Parameters.Add("@imgData", SqlDbType.Binary).Value = bytes;
cmd_sql.ExecuteNonQuery();
Reply
Answers (
6
)
C# How to make one item from Menustrip be default selected?
C# web browser