Click here to Skip to main content
15,907,000 members
Home / Discussions / C#
   

C#

 
GeneralRe: showing form from bottom wth timer Pin
eng.iris17-Sep-13 7:54
eng.iris17-Sep-13 7:54 
AnswerRe: showing form from bottom wth timer Pin
Midnight Ahri17-Sep-13 17:26
Midnight Ahri17-Sep-13 17:26 
GeneralRe: showing form from bottom wth timer Pin
eng.iris18-Sep-13 7:13
eng.iris18-Sep-13 7:13 
Questionwpf backgroundworker, execution of processes one after another Pin
Member 974759714-Sep-13 19:55
Member 974759714-Sep-13 19:55 
AnswerRe: wpf backgroundworker, execution of processes one after another Pin
Abhinav S14-Sep-13 22:18
Abhinav S14-Sep-13 22:18 
QuestionSave Images in SQl Server Pin
sigridslima14-Sep-13 17:13
sigridslima14-Sep-13 17:13 
GeneralRe: Save Images in SQl Server Pin
PIEBALDconsult14-Sep-13 18:12
mvePIEBALDconsult14-Sep-13 18:12 
GeneralRe: Save Images in SQl Server Pin
sigridslima15-Sep-13 14:57
sigridslima15-Sep-13 14:57 
Hello altered the way can save but not found the way to update and delete, please ask for a sample and how do I save if an image field null, because in this instance can not.

private void btnGravar_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(txtCaminho1.Text))
{
if (new FileInfo(txtCaminho1.Text).Exists)
{
if (!String.IsNullOrEmpty(txtCaminho1.Text))
{
if (!String.IsNullOrEmpty(txtCaminho2.Text))
{
if (new FileInfo(txtCaminho2.Text).Exists)
{
Image Image1 = Image.FromFile(txtCaminho1.Text);
Image Image2 = Image.FromFile(txtCaminho2.Text);
using (SqlConnection Conexao = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\fotos.mdf;Integrated Security=True;Connect Timeout=30"))
{
Conexao.Open();
using (SqlCommand Comando = Conexao.CreateCommand())
{
Comando.CommandType = CommandType.Text;
Comando.CommandText = "INSERT INTO tbFoto (descricao,foto,foto1) values(@descricao,@foto,@foto1);";
Comando.Parameters.Add("@descricao", System.Data.SqlDbType.VarChar, 50).Value = this.txtDescricao.Text;
Comando.Parameters.Add("@foto", SqlDbType.Image).Value = ConvertImageToByteArray(Image1, ImageFormat.Jpeg);
Comando.Parameters.Add("@foto1", SqlDbType.Image).Value = ConvertImageToByteArray(Image2, ImageFormat.Jpeg);
if (Comando.ExecuteNonQuery() > 0)
{
MessageBox.Show("Imagem gravada com êxito", "Imagem: Ok", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
Conexao.Close();
getImagensSQLServer(conexaoSQLServer);
LimparCampo();
btnGravar.Visible = false;
btnGravaNegocio.Visible = true;
}
}
else
{
MessageBox.Show("Imagem inválida", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
}

public byte[] ConvertImageToByteArray(Image image, ImageFormat imageFormat)
{
if (image == null)
return null;
MemoryStream ms = new MemoryStream();
image.Save(ms, imageFormat);
return ms.ToArray();
}

public Image ConvertByteArrayToImage(byte[] byteArray)
{
if (byteArray == null || byteArray.Length == 0)
{ return (null); }
return (Image.FromStream(new MemoryStream(byteArray)));
}
GeneralRe: Save Images in SQl Server Pin
PIEBALDconsult15-Sep-13 16:26
mvePIEBALDconsult15-Sep-13 16:26 
GeneralRe: Save Images in SQl Server Pin
sigridslima16-Sep-13 2:55
sigridslima16-Sep-13 2:55 
GeneralRe: Save Images in SQl Server Pin
PIEBALDconsult16-Sep-13 3:47
mvePIEBALDconsult16-Sep-13 3:47 
GeneralRe: Save Images in SQl Server Pin
sigridslima16-Sep-13 5:21
sigridslima16-Sep-13 5:21 
GeneralRe: Save Images in SQl Server Pin
PIEBALDconsult16-Sep-13 13:37
mvePIEBALDconsult16-Sep-13 13:37 
GeneralRe: Save Images in SQl Server Pin
sigridslima16-Sep-13 14:35
sigridslima16-Sep-13 14:35 
AnswerRe: Save Images in SQl Server Pin
OriginalGriff14-Sep-13 22:17
mveOriginalGriff14-Sep-13 22:17 
QuestionC# Application - SQL Syntax Problem Pin
Member 1026694314-Sep-13 16:34
Member 1026694314-Sep-13 16:34 
AnswerRe: C# Application - SQL Syntax Problem Pin
PIEBALDconsult14-Sep-13 17:17
mvePIEBALDconsult14-Sep-13 17:17 
GeneralRe: C# Application - SQL Syntax Problem Pin
Member 1026694315-Sep-13 11:03
Member 1026694315-Sep-13 11:03 
AnswerRe: C# Application - SQL Syntax Problem Pin
Dave Kreskowiak14-Sep-13 19:12
mveDave Kreskowiak14-Sep-13 19:12 
QuestionGet the value of RepositoryItemPictureEdit in GridControl Pin
nhanlaptrinh14-Sep-13 9:26
nhanlaptrinh14-Sep-13 9:26 
AnswerRe: Get the value of RepositoryItemPictureEdit in GridControl Pin
Richard MacCutchan14-Sep-13 21:45
mveRichard MacCutchan14-Sep-13 21:45 
QuestionDLLIMPORT - SENDMESSAGE Pin
M Riaz Bashir14-Sep-13 5:01
M Riaz Bashir14-Sep-13 5:01 
AnswerRe: DLLIMPORT - SENDMESSAGE Pin
Richard MacCutchan14-Sep-13 5:42
mveRichard MacCutchan14-Sep-13 5:42 
AnswerRe: DLLIMPORT - SENDMESSAGE Pin
TnTinMn14-Sep-13 8:39
TnTinMn14-Sep-13 8:39 
QuestionHelp Regarding Source Code Of Meshack Pin
Caiser Mahmood13-Sep-13 23:34
Caiser Mahmood13-Sep-13 23:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.