public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.pictureBox1.ImageLocation))
{
MessageBox.Show("请选择要插入的图片!");
return;
}
using (SqlConnection cn = new SqlConnection("Server=.;UID=sa;Pwd=sa;Database=cspro"))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO image_table(pic) VALUES (@pic)", cn))
{
cmd.Parameters.Add("@pic", SqlDbType.Image).Value = File.ReadAllBytes(this.pictureBox1.Ima