none
Sqldeki kayıtlı resimi buton yardımı ile masaüstüne kayıt etme? RRS feed

Tüm Yanıtlar

  • int id = 1;	
    byte[] picture = null;
    string extension = null;
    using (SqlConnection connection = new SqlConnection(@"server=.\SQLExpress2012;Trusted_connection=yes;Database=Test"))
    {
    	SqlCommand cmd = new SqlCommand(@"select Picture, Extension 
    	from myPictures 
    	where pictureId = @id", connection);
    	cmd.Parameters.Add("@id",SqlDbType.Int).Value = id;
    	connection.Open();
    	var reader = cmd.ExecuteReader();
    	if (reader.Read())
    	{
    		picture = (byte[])reader["Picture"];
    		extension = (string)reader["Extension"];
    	}
    	connection.Close();
    }
    if (picture != null)
    {
    	var fileName = $@"c:\temp\MyPicture.{extension}";
    	File.WriteAllBytes(fileName, picture);
    }
    



    How to create a Minimal, Reproducible Example
    The way to Go.
    World's most advanced open source (object-) relational Database.
    Flutter (for mobile, for web & desktop.

    13 Ocak 2020 Pazartesi 16:14
    Yanıtlayıcı