本文介绍了无法理解我错在哪里,数据库没有存储记录。请帮忙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void button_Pass_Click(object sender, EventArgs e)
{
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();
推荐答案
这篇关于无法理解我错在哪里,数据库没有存储记录。请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!