久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <legend id='NZiyA'><style id='NZiyA'><dir id='NZiyA'><q id='NZiyA'></q></dir></style></legend>
  1. <small id='NZiyA'></small><noframes id='NZiyA'>

    <tfoot id='NZiyA'></tfoot>

      <bdo id='NZiyA'></bdo><ul id='NZiyA'></ul>

      <i id='NZiyA'><tr id='NZiyA'><dt id='NZiyA'><q id='NZiyA'><span id='NZiyA'><b id='NZiyA'><form id='NZiyA'><ins id='NZiyA'></ins><ul id='NZiyA'></ul><sub id='NZiyA'></sub></form><legend id='NZiyA'></legend><bdo id='NZiyA'><pre id='NZiyA'><center id='NZiyA'></center></pre></bdo></b><th id='NZiyA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NZiyA'><tfoot id='NZiyA'></tfoot><dl id='NZiyA'><fieldset id='NZiyA'></fieldset></dl></div>
    1. 將圖像從 WPF 控件保存到 SQL Server DB

      Saving the Image from WPF control to SQL Server DB(將圖像從 WPF 控件保存到 SQL Server DB)

        <small id='ATxbM'></small><noframes id='ATxbM'>

          <bdo id='ATxbM'></bdo><ul id='ATxbM'></ul>
        • <tfoot id='ATxbM'></tfoot>

                <tbody id='ATxbM'></tbody>
              <i id='ATxbM'><tr id='ATxbM'><dt id='ATxbM'><q id='ATxbM'><span id='ATxbM'><b id='ATxbM'><form id='ATxbM'><ins id='ATxbM'></ins><ul id='ATxbM'></ul><sub id='ATxbM'></sub></form><legend id='ATxbM'></legend><bdo id='ATxbM'><pre id='ATxbM'><center id='ATxbM'></center></pre></bdo></b><th id='ATxbM'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ATxbM'><tfoot id='ATxbM'></tfoot><dl id='ATxbM'><fieldset id='ATxbM'></fieldset></dl></div>
            1. <legend id='ATxbM'><style id='ATxbM'><dir id='ATxbM'><q id='ATxbM'></q></dir></style></legend>

              • 本文介紹了將圖像從 WPF 控件保存到 SQL Server DB的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我有一個用 WPF 3.5 編寫的應用程序,它在某些時候將數據保存在 SQL Server 中包含圖像中,這是保存數據的代碼的一部分(注意 this.pictureImage 是一個 WPF Image 控件):-

                I have an application written in WPF 3.5 which at some point it saves the data in including an image in SQL Server, this is part of the code in saving the data (note this.pictureImage is a WPF Image control):-

                using (SqlCommand command = myConnection.CreateCommand())
                {
                    String sqlInsertCommand = "INSERT INTO Info_Id (idNumber, FirstName, Nationality, Image) VALUES (@idNumber, @firstName, @nationality, @image)";
                
                    command.CommandText = sqlInsertCommand;
                    command.CommandType = System.Data.CommandType.Text;
                
                    command.Parameters.AddWithValue("@idNumber", this.cardIdTextBlock.Text);
                    command.Parameters.AddWithValue("@firstName", this.fullNameTextBlock.Text);
                    command.Parameters.AddWithValue("@nationality", this.nationaltyTextBlock.Text);
                    command.Parameters.AddWithValue("@image", this.pictureImage);
                
                    command.ExecuteNonQuery();
                }
                

                運行此程序并單擊保存到數據庫按鈕后,出現以下錯誤.

                After I run this and click on the saving to DB button I got the following error.

                不存在從對象類型 System.Windows.Controls.Image 到已知托管提供程序的映射

                No mapping exists from object type System.Windows.Controls.Image to a known managed provider

                在 SQL Server 數據庫中,我有一行 (Picture (Image, null)).

                In the SQL Server database I have a row with (Picture (Image, null)).

                請多多指教.謝謝.

                推薦答案

                您無法在數據庫中保存 Image 控件.相反,您應該通過適當的位圖編碼器在 Image 控件的 Source 屬性中對圖像進行編碼,并將編碼的緩沖區存儲為字節數組.

                You can't save an Image control in your database. Instead you should encode the image in the Image control's Source property by an appropriate bitmap encoder and store the encoded buffer as byte array.

                byte[] buffer;
                var bitmap = pictureImage.Source as BitmapSource;
                var encoder = new PngBitmapEncoder(); // or one of the other encoders
                encoder.Frames.Add(BitmapFrame.Create(bitmap));
                
                using (var stream = new MemoryStream())
                {
                    encoder.Save(stream);
                    buffer = stream.ToArray();
                }
                
                // now store buffer in your DB
                

                這篇關于將圖像從 WPF 控件保存到 SQL Server DB的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會出現“數據類型轉換錯誤?使用 ExecuteNonQuery()?)
                How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                WinForms application design - moving documents from SQL Server to file storage(WinForms 應用程序設計——將文檔從 SQL Server 移動到文件存儲)
                    <legend id='A9rUH'><style id='A9rUH'><dir id='A9rUH'><q id='A9rUH'></q></dir></style></legend>
                      <bdo id='A9rUH'></bdo><ul id='A9rUH'></ul>

                      <tfoot id='A9rUH'></tfoot>
                      <i id='A9rUH'><tr id='A9rUH'><dt id='A9rUH'><q id='A9rUH'><span id='A9rUH'><b id='A9rUH'><form id='A9rUH'><ins id='A9rUH'></ins><ul id='A9rUH'></ul><sub id='A9rUH'></sub></form><legend id='A9rUH'></legend><bdo id='A9rUH'><pre id='A9rUH'><center id='A9rUH'></center></pre></bdo></b><th id='A9rUH'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='A9rUH'><tfoot id='A9rUH'></tfoot><dl id='A9rUH'><fieldset id='A9rUH'></fieldset></dl></div>

                          <tbody id='A9rUH'></tbody>

                          <small id='A9rUH'></small><noframes id='A9rUH'>

                        1. 主站蜘蛛池模板: 粉嫩一区二区三区性色av | 我要看黄色录像一级片 | h在线看| 精品久久精品 | 国产精品精品视频一区二区三区 | 97精品超碰一区二区三区 | 九九伊人sl水蜜桃色推荐 | 秋霞电影一区二区 | 亚洲精品二区 | 免费在线看黄 | 久久另类 | 成人在线视频免费播放 | 精品免费视频 | av资源中文在线 | 欧美群妇大交群中文字幕 | 欧美黄a| 韩日一区二区三区 | 欧美在线一区二区三区 | 欧美久久视频 | 日韩中文字幕 | 黄视频网站在线 | 成人欧美一区二区三区黑人孕妇 | 老牛嫩草一区二区三区av | 国产高清视频在线 | 国产中文字幕在线观看 | 狠狠爱综合网 | 亚洲国产一区二区三区 | 一区二区手机在线 | 激情五月婷婷 | 成人午夜在线 | 蜜臀网| 欧美精品在线一区二区三区 | 国产小视频在线 | 亚洲福利一区 | 国产精品毛片无码 | 欧美日韩电影一区 | 一级一级一级毛片 | 国产精品视频专区 | 欧美在线国产精品 | 成人精品鲁一区一区二区 | 精品国产区 |