c #sql查询问题

时间:2011-04-10 12:43:26

标签: c# sql

这是OCR。我的系统允许用户输入由字符组成的图像,填写特定字符和描述。输入数据将插入数据库。这是我的问题,如果用户想要输入具有相同字符但是使用不同字体的图像,则不需要重新键入字符和描述。他们可能只需要使用导入按钮来导入现有图像,让系统知道两个字符是否相同。因此,当用户输入图像供系统扫描时,系统可能知道不同字体的字符。

然后我如何编码系统以通知系统当用户导入现有字符时该字符是相同的?

区域图书馆培训(Tab2_Component)

    private void Browse1_Click(object sender, EventArgs e)
    {
        try
        {
            //open file dialog for the users to input image to the system
            OpenFileDialog open = new OpenFileDialog();
            //Set default directory to the open file dialog
            open.InitialDirectory = @"C:\Users\Shen\Desktop";

            //limit input image type for the users
            open.Filter = "Image Files(*.jpg; *.jpeg)|*.jpg; *.jpeg";

            if (open.ShowDialog() == DialogResult.OK)
            {
                singleFileInfo = new FileInfo(open.FileName);
                string dirName = System.IO.Path.GetDirectoryName(open.FileName);
                imgLoc.Text = open.FileName;
            }
        }
        catch (Exception)
        {
            throw new ApplicationException("Failed loading image");
        }
    }

    private void typeRadio_CheckedChanged(object sender, EventArgs e)
    {
        //set the textbox to editable and the "import" button unclickable when user select the "Type Character" radio button
        CharTB.ReadOnly = false;
        ImportButton.Enabled = false;
        DescTB.ReadOnly = false;
    }

    private void importRadio_CheckedChanged(object sender, EventArgs e)
    {
        //set the "import" button to clickable and the textbox to uneditable when the user select "Import Existing" radio button
        ImportButton.Enabled = true;
        CharTB.ReadOnly = true;
        DescTB.ReadOnly = true;
    }

    private void AddBt_Click(object sender, EventArgs e)
    {
        con = new System.Data.SqlClient.SqlConnection();
        con.ConnectionString = "Data Source=SHEN-PC\\SQLEXPRESS;Initial Catalog=CharacterImage;Integrated Security=True";
        con.Open();

        //set variables to the textbox.text
        String ImageLocation = imgLoc.Text;
        String typeName = CharTB.Text;
        String ImportExt = importTB.Text;
        String CharDesc = DescTB.Text;
        String fileName = System.IO.Path.GetFileName(ImageLocation);
        String savePath = @"C:\Users\Shen\Desktop\LenzOCR\LenzOCR\WindowsFormsApplication1\ImageFile\" + fileName;

        inputImageBox.Image = Image.FromFile(ImageLocation);
        inputImageBox.Image.Save(savePath);

        String insertData = "INSERT INTO CharacterImage(ImageName, ImagePath, Character, CharacterDescription) VALUES('"+fileName+"', '"+savePath+"', '"+typeName+"', '"+CharDesc+"')";
        SqlCommand cmd = new SqlCommand(insertData, con);
        cmd.ExecuteNonQuery();
        con.Close();
        MessageBox.Show("Character Inserted", "Insert Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
        descDisplayTB.Text = typeName + "\r\n\r\n" + CharDesc;
        //set the Textbox to empty and the "Type Character" textboxt to uneditable 
        //and the "Import" button to unclickable after user add the data into the database
        imgLoc.Text = "";
        CharTB.Text = "";
        importTB.Text = "";
        DescTB.Text = "";
        CharTB.ReadOnly = true;
        ImportButton.Enabled = false;
    }

    private void button2_Click(object sender, EventArgs e)
    {
        descDisplayTB.Text = "";
        pictureBox1.Image = null;
    }
    #endregion

1 个答案:

答案 0 :(得分:0)

请原谅我,如果我误解了你的问题,但似乎你需要一个多表数据库才能做到这一点

一个例子

  1. 用户+字体详细信息(我不明白字体的详细信息)
  2. 上传详情,例如扫描项目
  3. 就数据库而言,执行

    可能更有用
    1. 用户
    2. 图片详情
    3. user_id和image_id之间的链接
    4. 您可以做的是询问他们是否要根据同一图像插入另一个,而不是重置描述和字符等。

      我并没有真正理解它的字体部分。