保存的數據經過字符串後會顯示錯誤給定的路徑格式不受支持,我做錯了什麼或者我把url
轉換器代碼放入錯誤的地方?錯誤System.NotSupportedException:不支持給定路徑的格式
try
{
connect.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connect;
command.CommandText = string.Format("insert into RegisterItem([Name], [Url],[Description], [Price]) values('{0}','{1}','{2}','{3}')",
ItemName.Text,
ItemUrl.Text,
ItemDescription.Text,
ItemPrice.Text);
command.ExecuteNonQuery();
MessageBox.Show("Data Saved");
txtID1.Text = txtUsername.Text;
txtName1.Text = ItemName.Text;
txtDescription1.Text = ItemDescription.Text;
txtPrice1.Text = ItemPrice.Text;
ItemName.Text = "";
ItemDescription.Text = "";
ItemPrice.Text = "";
string str = ItemUrl.Text;
pictureBox1.ImageLocation = str;
string str1 = textBox1.Text;
Image img = Image.FromFile(str);
pictureBox1.Image = img;
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}
finally
{
if (Connect != null) { connect.Close(); }
}
'ItemUrl'中有什麼?我們看不到你的電腦:) – Pikoh
這是一個文本框,你輸入的URL和圖片將被加載到pictureBox1 –
但是引起異常的'ItemUrl.Text'值是什麼? – slawekwin