我在這裏做一個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;
}
你可以進一步解釋如何做到這一點? – joonshen 2011-04-11 14:15:42