من این کد ها رو نوشتم ولی داخل sql هیچی ثبت نمیشه تو دردسر بزرگی افتادم چون برای اداره ام دارم می نویسم و دچار مشکل شدم.


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.Data.SqlClient;
using System.IO;
using System.Drawing.Imaging;

namespace final_doctor
{
public partial class sabt : Form
{
SqlConnection cn = new SqlConnection("Data source=172.16.8.4;Initial Catalog=final doctor;Integrated security=true;");
SqlDataAdapter adap = new SqlDataAdapter();
DataTable dt = new DataTable();


public sabt()
{
InitializeComponent();
}




private void button6_Click(object sender, EventArgs e)
{

openFileDialog1.Filter = "jpg Files |*.jpg|PNG FIles |*.png";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
pictureBox1.Image = new Bitmap(openFileDialog1.FileName);

}

private void button1_Click(object sender, EventArgs e)
{
sabt S=new sabt();

SqlCommand cmd = new SqlCommand("INSERT INTO [final doctor]([name],[family],[fhater],[jenseyat],[nezam],[code],[country],[ostan],[shahrestan],[telwork],[mobile],[reshteh],[madrak],[vaestekhdam],[khed1],[khed2],[khed3],[khed4],[heatm],[heatn],[matabd],[matabn],[address],[photo],[parvanehl],[parvaneht],[vazeatf],[vazeatgh]) VALUES (@name,@family,@father,@jenseyat,@nezam,@code,@cou ntry,@ostan,@shahrestan,@telwork,@mobile,@reshteh, @madrak,@vastekhdam,@khed1,@khed2,@khed3,@khed4,@h eatm,@heatn,@matabd,@matabn, @address,@photo,@parvanehl,@parvaneht,@vazeatf,@va zeatgh,0)", cn);
try
{


string name = textBox1.Text;
string family = textBox2.Text;
string father = textBox3.Text;
string jenseyat = comboBox1.Text;
string nezam = textBox4.Text;
string code = textBox5.Text;
string country = textBox10.Text;
string ostan = comboBox2.Text;
string shahrestan = comboBox3.Text;
string telwork = textBox6.Text;
string mobile = textBox7.Text;
string reshteh = comboBox4.Text;
string madrak = comboBox6.Text;
string vaestekhdam = comboBox5.Text;
string khed1 = comboBox9.Text;
string khed2 = comboBox7.Text;
string khed3 = comboBox10.Text;
string khed4 = comboBox8.Text;
Image photo = pictureBox1.Image;
var heatm = checkBox1.Checked;
var heatn = checkBox2.Checked;
var matabd = checkBox5.Checked;
var matabn = checkBox6.Checked;
string address = textBox9.Text;
var parvanehl = checkBox4.Checked;
var parvaneht = checkBox3.Checked;
var vazeatf = radioButton1.Checked;
var vazeatgh = radioButton2.Checked;

cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@family", family);
cmd.Parameters.AddWithValue("@father", father);
cmd.Parameters.AddWithValue("@jenseyat", jenseyat);
cmd.Parameters.AddWithValue("@nezam", nezam);
cmd.Parameters.AddWithValue("@code", code);
cmd.Parameters.AddWithValue("@country", country);
cmd.Parameters.AddWithValue("ostan", ostan);
cmd.Parameters.AddWithValue("@shahrestan", shahrestan);
cmd.Parameters.AddWithValue("@telwork", telwork);
cmd.Parameters.AddWithValue("@mobile", mobile);
cmd.Parameters.AddWithValue("@reshteh", reshteh);
cmd.Parameters.AddWithValue("@madrak", madrak);
cmd.Parameters.AddWithValue("@vaestekhdam", vaestekhdam);
cmd.Parameters.AddWithValue("@khed1", khed1);
cmd.Parameters.AddWithValue("@khed2", khed2);
cmd.Parameters.AddWithValue("@khed3", khed3);
cmd.Parameters.AddWithValue("@khed4", khed4);
cmd.Parameters.AddWithValue("@heatm", heatm);
cmd.Parameters.AddWithValue("@heatn", heatn);
cmd.Parameters.AddWithValue("@matabd", matabd);
cmd.Parameters.AddWithValue("@matabn", matabn);
cmd.Parameters.AddWithValue("@address", address);
cmd.Parameters.AddWithValue("@photo", photo);
cmd.Parameters.AddWithValue("@parvanehl", parvanehl);
cmd.Parameters.AddWithValue("@parvaneht", parvaneht);
cmd.Parameters.AddWithValue("@vazeatf", vazeatf);
cmd.Parameters.AddWithValue("@vazeatgh", vazeatgh);

Bitmap bmp = (Bitmap)pictureBox1.Image;
MemoryStream ms = new MemoryStream();
bmp.Save(ms, bmp.RawFormat);

MessageBox.Show("image saved");
ms.Close();

cn.Open();
cmd.ExecuteNonQuery();
cn.Close();

MessageBox.Show("رکورد با موفقیت ثبت شد ", "ثبت ", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
textBox10.Text = "";
textBox6.Text = "";
textBox7.Text = "";
textBox9.Text = "";
pictureBox1.Image = null;

}

catch (Exception ex)
{
MessageBox.Show("error");
}
}
}

}