Ver Mensaje Individual
Antiguo 22-jun-2008, 13:45   #2 (permalink)
Peterpay
Peterpay tiene algunos puntos positivos de karma
 
Avatar de Peterpay
 
Fecha de Ingreso: septiembre-2007
Ubicación: Mexico
Mensajes: 2.403
Enviar un mensaje por MSN a Peterpay Enviar un mensaje por Skype™ a Peterpay
Respuesta: Guardar imagenes y textos largos.

aqui te dejo un codigo ejemplo como guardar ambos imagenes y textoss lasrgos

SqlCommand com = new SqlCommand("insert into StudentProfile(Roll,Photo,resume)values(@roll,@pho to,@resume)", con);
com.Parameters.Add(new SqlParameter("@roll", SqlDbType.Int));
com.Parameters.Add(new SqlParameter("@photo", SqlDbType.Image));
com.Parameters.Add(new SqlParameter("@resume", SqlDbType.NText));

FileStream stream = new FileStream(TxtPhoto.Text, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(stream);
byte[] photo = reader.ReadBytes((int)stream.Length);
reader.Close();
stream.Close();

FileStream stream1 = new FileStream(TxtResume.Text, FileMode.Open, FileAccess.Read);
StreamReader reader1 = new StreamReader(stream1);
string resume = reader1.ReadToEnd();
char[] chars = resume.ToCharArray();

com.Parameters["@roll"].Value = TxtRoll.Text;
com.Parameters["@photo"].Value = photo;
com.Parameters["@resume"].Value = chars;

con.Open();
com.ExecuteNonQuery();
con.Close();
MessageBox.Show("Profile saved");
__________________
Saludos Peterpay - MCPD EAD
Directorio
Aprende .NET
Protege tu Email
Peterpay esta en línea ahora   Responder Citando