久久久久久久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的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時送ChatGPT賬號..

                我有一個用 WPF 3.5 編寫的應(yīng)用程序,它在某些時候?qū)?shù)據(jù)保存在 SQL Server 中包含圖像中,這是保存數(shù)據(jù)的代碼的一部分(注意 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();
                }
                

                運行此程序并單擊保存到數(shù)據(jù)庫按鈕后,出現(xiàn)以下錯誤.

                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 數(shù)據(jù)庫中,我有一行 (Picture (Image, null)).

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

                請多多指教.謝謝.

                推薦答案

                您無法在數(shù)據(jù)庫中保存 Image 控件.相反,您應(yīng)該通過適當(dāng)?shù)奈粓D編碼器在 Image 控件的 Source 屬性中對圖像進(jìn)行編碼,并將編碼的緩沖區(qū)存儲為字節(jié)數(shù)組.

                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
                

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

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

                相關(guān)文檔推薦

                Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數(shù)據(jù)庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發(fā)
                How to create a login to a SQL Server instance?(如何創(chuàng)建對 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()?(為什么會出現(xiàn)“數(shù)據(jù)類型轉(zhuǎn)換錯誤?使用 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 應(yīng)用程序設(shè)計——將文檔從 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. 主站蜘蛛池模板: 亚洲一区久久 | 国产精品一区二区三区久久 | 亚洲一区二区三区在线 | 欧美精品在线免费观看 | 先锋资源亚洲 | 狠狠躁夜夜躁人人爽天天高潮 | 成人国产精品久久 | 91免费在线视频 | 久久精品色欧美aⅴ一区二区 | 伊人影院在线观看 | 国产一级片 | 免费观看视频www | 妖精视频一区二区三区 | 国产黄色小视频 | 久久精品99国产精品 | 久国久产久精永久网页 | 午夜99| www精品美女久久久tv | 欧美精品一区在线 | 中文字幕av一区二区三区 | 午夜欧美a级理论片915影院 | 久久久久久亚洲 | 涩涩视频大全 | 亚洲精品综合 | 中文字幕二区三区 | 羞羞的视频免费在线观看 | 亚洲成人午夜电影 | 日本一区二区三区在线观看 | 欧美中文字幕 | 成人影| 欧美一区二区免费在线 | 91中文字幕 | 久久亚洲综合 | av黄色在线 | 欧美日韩专区 | 一区二区三区中文字幕 | 中文字幕国产精品 | 欧美在线一区二区三区 | 亚洲精品粉嫩美女一区 | 亚洲一区二区在线视频 | 99久久久久久久 |