SqlConnection con1 = new SqlConnection("Data Source=JAYI-PC\\SQLEXPRESS;Initial Catalog=db-ub;Integrated Security=True");
con1.Open();
Image img = pictureBox_UB.Image;
byte[] arr;
ImageConverter converter = new ImageConverter();
arr = (byte[])converter.ConvertTo(img, typeof(byte[]));
//SqlCommand cmd1 = new SqlCommand("Insert into Visitors (Image) values('"+arr+"')");
//cmd1.ExecuteNonQuery();
string s = "";
if (comboBox_TOWHOM.SelectedIndex >= 0)
s = comboBox_TOWHOM.Items[comboBox_TOWHOM.SelectedIndex].ToString();
string c = "";
if (comboBox_color.SelectedIndex >= 0)
c = comboBox_color.Items[comboBox_color.SelectedIndex].ToString();
string n = "";
if(numericUpDown_Person.Value >= 0)
n = numericUpDown_Person.Value.ToString();
string prps = string.Empty;
if(radioButton_OFFICIAL.Checked)
{
prps = "Official";
}
else if(radioButton_PERSONAL.Checked)
{
prps = "Personal";
}
SqlCommand cmd1 = new SqlCommand("Insert into Visitors(Id,Visitor Name,Organisation Name,Phone No,No of Person,Whom to Visit,Purpose,Color Code,Day In,Time In, Image)values("+textBox_Id.Text+",'" + textBox_NameV.Text + "','" + textBox_Org.Text + "'," + textBox_Phn.Text + ",'" + n + "','" + s + "','" + prps + "','" + c + "','" + textBox_Dayin.Text + "','" + textBox_timeR.Text + "'," + arr + ")",con1);
cmd1.ExecuteNonQuery();
MessageBox.Show("Record has been inserted");
con1.Close();
Loading

Upendra Pratap ShahiPosted Jun 17, 2015, 4:45 AM
con1.Open();
Image img = pictureBox_UB.Image;
byte[] arr;
ImageConverter converter = new ImageConverter();
arr = (byte[])converter.ConvertTo(img, typeof(byte[]));
//SqlCommand cmd1 = new SqlCommand("Insert into Visitors (Image) values('"+arr+"')");
//cmd1.ExecuteNonQuery();
string s = "";
if (comboBox_TOWHOM.SelectedIndex >= 0)
s = comboBox_TOWHOM.Items[comboBox_TOWHOM.SelectedIndex].ToString();
string c = "";
if (comboBox_color.SelectedIndex >= 0)
c = comboBox_color.Items[comboBox_color.SelectedIndex].ToString();
string n = "";
if(numericUpDown_Person.Value >= 0)
n = numericUpDown_Person.Value.ToString();
string prps = string.Empty;
if(radioButton_OFFICIAL.Checked)
{
prps = "Official";
}
else if(radioButton_PERSONAL.Checked)
{
prps = "Personal";
}
Jayita RoyPosted Jun 17, 2015, 2:27 AM
Upendra Pratap ShahiPosted Jun 17, 2015, 2:19 AM
Jayita RoyPosted Jun 17, 2015, 1:25 AM
Upendra Pratap ShahiPosted Jun 17, 2015, 12:34 AM
con1.Open();
Image img = pictureBox_UB.Image;
byte[] arr;
ImageConverter converter = new ImageConverter();
arr = (byte[])converter.ConvertTo(img, typeof(byte[]));
//SqlCommand cmd1 = new SqlCommand("Insert into Visitors (Image) values('"+arr+"')");
//cmd1.ExecuteNonQuery();
string s = "";
if (comboBox_TOWHOM.SelectedIndex >= 0)
s = comboBox_TOWHOM.Items[comboBox_TOWHOM.SelectedIndex].ToString();
string c = "";
if (comboBox_color.SelectedIndex >= 0)
c = comboBox_color.Items[comboBox_color.SelectedIndex].ToString();
string n = "";
if(numericUpDown_Person.Value >= 0)
n = numericUpDown_Person.Value.ToString();
string prps = string.Empty;
if(radioButton_OFFICIAL.Checked)
{
prps = "Official";
}
else if(radioButton_PERSONAL.Checked)
{
prps = "Personal";
}
Manoj BhoirPosted Jun 16, 2015, 11:04 PM
Instead of Organisation Name
Try
theLizardPosted Jun 16, 2015, 9:18 PM
Jayita RoyPosted Jun 16, 2015, 1:46 PM
Manoj BhoirPosted Jun 16, 2015, 1:24 PM