반응형
// Create a byte[] from the input file
int len = Upload.PostedFile.ContentLength;
byte[] image = new byte[len];
Upload.PostedFile.InputStream.Read (image, 0, len);
// Insert the image and comment into the database
SqlConnection connection = new SqlConnection (@"server=test;database=pub;uid=sa;pwd=1234");
try
{
connection.Open ();
SqlCommand cmd = new SqlCommand ("insert into Image "
+ "(Image, memo) values (@image, @text)", connection);
cmd.Parameters.Add ("@image", image);
cmd.Parameters.Add ("@text", "이미니 넣기 테스트");
cmd.ExecuteNonQuery ();
}
finally
{
connection.Close ();
}
int len = Upload.PostedFile.ContentLength;
byte[] image = new byte[len];
Upload.PostedFile.InputStream.Read (image, 0, len);
// Insert the image and comment into the database
SqlConnection connection = new SqlConnection (@"server=test;database=pub;uid=sa;pwd=1234");
try
{
connection.Open ();
SqlCommand cmd = new SqlCommand ("insert into Image "
+ "(Image, memo) values (@image, @text)", connection);
cmd.Parameters.Add ("@image", image);
cmd.Parameters.Add ("@text", "이미니 넣기 테스트");
cmd.ExecuteNonQuery ();
}
finally
{
connection.Close ();
}
반응형