2011-04-11 60 views
1

我在這裏做一個OCR。在我的系統中,用戶輸入圖像,字符和描述。c#查詢數據庫幫助

如果用戶想要輸入另一個具有相同字符和描述的圖像,用戶只需要導入現有的圖像來告訴系統該字符和描述是相同的,這樣他們就不需要重新輸入字符和描述再次。

任何人都知道如何做到這一點?

這裏是我的代碼:

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

回答

0

可能是以下步驟工作:

  1. 要求用戶輸入圖片ID [可瀏覽或別的東西]的詳細資料將被複制,其中。
  2. 從數據庫中獲取該圖像的詳細信息。
  3. 插入最新更新的圖像與數據庫中提取的詳細信息。
+0

你可以進一步解釋如何做到這一點? – joonshen 2011-04-11 14:15:42

0

在輸入第一張圖像後,我不會清除字符和說明字段。這樣用戶只需選擇下一張圖片,然後重新提交表格即可。

0

我對你的答案很高。

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