TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sousa Pambo
NA
92
23.9k
insert images into sql
Mar 3 2015 6:31 PM
I have a bug inserting two images into sql what is wrong with this
public void LancaResponsavel_1(UIL.frmCadAluno frmAl)
{
System.Text.StringBuilder sqlBuilder = new System.Text.StringBuilder();
sqlBuilder.Append("INSERT INTO tbResponsavel");
sqlBuilder.Append("(apelidoR, idAlunoR, nomeR, contactoR, sexoR, dtNascR, parentescoR, bairroR, Av_ruaR, qrteraoR, fotoR, CasaR, apelidoR2, nomeR2, contactoR2, sexoR2, dtNascR2, parentescoR2, bairroR2, Av_ruaR2, qrteraoR2,fotoR2 , fotoRCasaR2)");
sqlBuilder.Append(" VALUES ('");
sqlBuilder.Append(frmAl.tbApelidResp1.Text + "','"); //1
sqlBuilder.Append(frmAl.tbRefCadastro.Text + "','"); //2
sqlBuilder.Append(frmAl.tbNomResp1.Text + "','"); //3
sqlBuilder.Append(frmAl.tbcntctoR1.Text + "','"); //4
sqlBuilder.Append(frmAl.sexoR + "','"); //5
sqlBuilder.Append(frmAl.dtNascResp1.Text + "','"); //6
sqlBuilder.Append(frmAl.cbParentescResp1.Text + "','"); //7
sqlBuilder.Append(frmAl.tbBairroResp1.Text + "','"); //8
sqlBuilder.Append(frmAl.tbAvenResp1.Text + "','"); //9
sqlBuilder.Append(frmAl.tbQrtResp1.Text + "',"); //10
sqlBuilder.Append("@PicResp1,'"); //11
sqlBuilder.Append(frmAl.tbCasaResp1.Text + "','"); //12
sqlBuilder.Append(frmAl.tbapelidResp2.Text + "','"); //1
sqlBuilder.Append(frmAl.tbNomResp2.Text + "','"); //2
sqlBuilder.Append(frmAl.tbCntactoR2.Text + "','"); //3
sqlBuilder.Append(frmAl.sexoR2 + "','"); //4
sqlBuilder.Append(frmAl.dtNascResp2.Text + "','"); //5
sqlBuilder.Append(frmAl.cbParentescResp2.Text + "','"); //6
sqlBuilder.Append(frmAl.tbBairroResp2.Text + "','"); //7
sqlBuilder.Append(frmAl.tbAvenResp2.Text + "','"); //8
sqlBuilder.Append(frmAl.tbQrtResp2.Text + "','"); //9
sqlBuilder.Append("@PicResp2,'"); //10
sqlBuilder.Append(frmAl.tbCasaResp2.Text + "')"); //11
using (SqlConnection myconn = new SqlConnection(con.stringConexaoRH()))
try
{
myconn.Open();
using (SqlCommand cm = new SqlCommand(sqlBuilder.ToString(), myconn))
{
MemoryStream ms = new MemoryStream();
frmAl.pbFotoResp1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
cm.Parameters.Add("@PicResp1", SqlDbType.Image).Value = ms.ToArray();
frmAl.pbFotoResp2.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
cm.Parameters.Add("@PicResp2", SqlDbType.Image).Value = ms.ToArray();
cm.ExecuteNonQuery();
}
}
catch (Exception ex)
{
MessageBox.Show("" + ex);
}
}
Reply
Answers (
3
)
CHECK A LISTVIEW WITH A SPECIFIC DATA
Loop through to show values in a Chart