hii friends,i am developing a windows application in c#,in that i have 2 buttons 1 for browsing the file and the other to save that image to sqlserver database and i have a textbox too to enter description of that image..how the thing gets done in c#
help me friends i am very new to c#
Loading

Hiren SoniRank #694 · 3.5K reputationPosted Dec 25, 2009, 4:49 PM EST
Hiren SoniRank #694 · 3.5K reputationPosted Dec 25, 2009, 5:09 PM EST
Hiren SoniRank #694 · 3.5K reputationPosted Dec 25, 2009, 5:12 PM EST
kiran kumarRank #3,110 · 461 reputationPosted Dec 25, 2009, 5:23 PM EST
this is my email id [email protected]
kiran kumarRank #3,110 · 461 reputationPosted Dec 25, 2009, 5:31 PM EST
i have witten my code like this and it is showing lots of errors.......my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//private void up()
//{
OpenFileDialog open = new OpenFileDialog();
open.InitialDirectory = @":D\";
open.Filter = "Imagefile(*.jpeg;*.gif;*.bmp;)|*.jpeg;*.gif;*.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
string imagename;
imagename = open.FileName;
Bitmap bmp = new Bitmap(imagename);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.Image = (Image)bmp;
private void up()
{
if (imagename != "")
{
FileStream fs = new FileStream(@imagename, FileMode.Open, FileAccess.Read);
byte[] picbyte = new byte[fs.Length];
fs.Read(picbyte, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
SqlConnection con = new SqlConnection("Data Source=DOMMARAJ-70D924\\SQLEXPRESS;Initial Catalog=kiran;Integrated Security=True");
con.Open();
string querystring;
querystring = "insert into image(pic) values('"+picbyte+"')";
SqlCommand cmd = new SqlCommand(querystring, con);
SqlParameter img = new SqlParameter("@pic", SqlDbType.Image);
img.Value = picbyte;
cmd.Parameters.Add(img);
cmd.ExecuteNonQuery();
}
con.Close();
}
}
}
private void button2_Click(object sender, EventArgs e)
{
this.up();
}
}
}
Hiren SoniRank #694 · 3.5K reputationPosted Dec 25, 2009, 5:52 PM EST
Hiren SoniRank #694 · 3.5K reputationPosted Dec 25, 2009, 6:15 PM EST