簡體   English   中英

C#查詢數據庫幫助

[英]c# query database help

我在這里進行OCR。 在我的系統中,用戶輸入圖像,字符和描述。

如果用戶要輸入另一張具有相同字符和描述的圖像,則只需導入現有的圖像即可告訴系統該字符和描述相同,因此無需重新輸入字符和描述。再次。

有人知道該怎么做嗎?

這是我的代碼:

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;
    }

我為您提供了一個高級答案。

我會保留最近識別或加載的數據的集合。 然后,在加載每個項目時,您可以創建一個滾動窗口以選擇最近上載到數據庫的字符圖像,因此該人員無需將其與您的訓練集重新關聯。

可能會按照以下步驟工作:

  1. 要求用戶輸入要復制其詳細信息的圖像ID(可能是瀏覽的圖像或其他內容)。
  2. 從數據庫中獲取該圖像的詳細信息。
  3. 在數據庫中插入帶有獲取的詳細信息的新更新的圖像。

輸入第一張圖像后,我不會清除字符和描述字段。 這樣,用戶只需選擇下一張圖像,然后重新提交表單即可。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM