C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Images »

Save image into Database and folder in C#


Posted Date: 03 May 2009    Resource Type: Code Snippets    Category: Images
Author: Dharmendra BanoliyaMember Level: Gold    
Rating: 1 out of 5Points: 10



Code of cs file

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;

public void DataConnection()
{
con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["RDCConnection"]);
con.Open();
}
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnSave_Click(object sender, EventArgs e)
{
DataConnection();
cmd = new SqlCommand();
cmd.CommandText = "Insert into imagetest(imgname)values('" + FileUpload1.FileName + "')";
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
string strPath = Server.MapPath("~/img/");
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(strPath + FileUpload1.FileName);
}
cmd.ExecuteNonQuery();

Response.Write("File save successfully");
}

}


Code of aspx page

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnSave" runat="server" onclick="btnSave_Click" Text="Save" />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Code to save image into database in C#  .  C# code to save image in database  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Custom drawing in Images
Previous Resource: Convert An Image to Thumbnail In VB .Net
Return to Discussion Resource Index
Post New Resource
Category: Images


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use