This is a migrated thread and some comments may be shown as answers.

Upload File + Stored Procedure Help

1 Answer 60 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
WebGeek
Top achievements
Rank 1
WebGeek asked on 10 Feb 2009, 03:05 AM
I am new to C# programming (programming in general) and I am trying to figure out how to upload a file to a directory on my web server and save the file name to the database using a stored procedure.  Do you have any step-by-step instructions or a sample project?

1 Answer, 1 is accepted

Sort by
0
WebGeek
Top achievements
Rank 1
answered on 11 Feb 2009, 05:25 AM
Disregard - my solution below:

protected void btnAdd_Click(object sender, EventArgs e)  
        {  
foreach (UploadedFile f in RadUpload1.UploadedFiles)  
            {  
                f.SaveAs(Server.MapPath("~/Images/") + f.GetName(), true);  
 
 
                SqlCommand cmd = new SqlCommand("cms_utls_Image_Add"new SqlConnection(ConfigurationManager.ConnectionStrings["App"].ToString()));  
                cmd.CommandType = CommandType.StoredProcedure;  
 
                cmd.Parameters.AddWithValue("@Name", radtextboxName.Text);  
                cmd.Parameters.AddWithValue("@Photo", f.GetName());  
                cmd.Connection.Open();  
                cmd.ExecuteNonQuery();  
                cmd.Connection.Close();  
                pnlAdd.Visible = false;  
                pnlSuccess.Visible = true;  
                lblNameAdded.Text = "<b>" + radTextBoxName.Text + "</b> has been added to the database using a Stored Procedure.";  
            } 
Tags
Upload (Obsolete)
Asked by
WebGeek
Top achievements
Rank 1
Answers by
WebGeek
Top achievements
Rank 1
Share this question
or