Ceci est mon bouton mise à jour événement click:J'ai solution cherche pour cela, mais en ayant toujours erreur dans ma requête de mise à jour au moment de l'image télécharger
private void btnUpdate_Click(object sender, EventArgs e)
{
try
{
if (ValidateAll())
{
SetValues();
_objHotel_EL.HotelID = HotelId;
_objHotel_EL.CommandName = "Update_HotelDetails";
int update = _objHotel_BL.Insert_Hotel(_objHotel_EL);
if (update > 0)
{
MessageBox.Show("Hotel Details Updated");
ClearAll();
}
else
{
MessageBox.Show("Already Exists");
ClearAll();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
voici mon code qui est utilisé pour définir et télécharger l'image et d'autres paramètres:
private void SetValues()
{
_objHotel_EL.HotelName = txtHotelName.Text.Trim();
_objHotel_EL.PhoneNo = txtPhoneNo.Text.Trim();
_objHotel_EL.Address = txtAddress.Text.Trim();
_objHotel_EL.EmailId = txtEmailId.Text.Trim();
_objHotel_EL.WebSite = txtWebsite.Text.Trim();
_objHotel_EL.CurrID = CommanValue.CurrID;
if (flag == 1)
{
_objHotel_EL.BinaryImage = ReadFile(labelImagePath.Text);
_objHotel_EL.ImagePath = labelImagePath.Text;
}
else
{
if (imageData == null)
{
string path = System.AppDomain.CurrentDomain.BaseDirectory.Replace("\\Debug", "");
path = path.Replace("\\bin", "");
path = path.Replace("\\x86", "");
path = path + "Images\\NoImage1.png";
labelImagePath.Text = path;
imageData = ReadFile(labelImagePath.Text);
_objHotel_EL.ImagePath = path;
}
_objHotel_EL.ImagePath = labelImagePath.Text;
_objHotel_EL.BinaryImage = (byte[])imageData;
}
}
Ceci est du code de ReadFile:
private byte[] ReadFile(string strPath)
{
byte[] data = null;
FileInfo fInfo = new FileInfo(strPath);
long numBytes = fInfo.Length;
FileStream fstream = new FileStream(strPath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fstream);
data = br.ReadBytes((int)numBytes);
return data;
}
S'il vous plaît aidez-moi o ut parce que c'est en me donnant une erreur The conversion is not supported. [ Type to convert from (if known) = nvarchar, Type to convert to (if known) = image ]
pendant que j'utilise sql server compact dans Visual Studio 2012 en utilisant C#.
Dans la base de données, le type de données de l'image est l'image.
Quel est le type renvoyé de votre fonction * ReadFile *? –
Afficher le code de la méthode ReadFile –
J'ai mis à jour ma question. –