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 SoniPosted Dec 25, 2009, 9:49 PM
Hiren SoniPosted Dec 25, 2009, 11:15 PM
Hiren SoniPosted Dec 25, 2009, 10:52 PM
kiran kumarPosted Dec 25, 2009, 10:31 PM
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();
}
}
}
kiran kumarPosted Dec 25, 2009, 10:23 PM
this is my email id [email protected]
Hiren SoniPosted Dec 25, 2009, 10:12 PM
Hiren SoniPosted Dec 25, 2009, 10:09 PM