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

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

        <bdo id='9DnNr'></bdo><ul id='9DnNr'></ul>

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

      <tfoot id='9DnNr'></tfoot>
    2. C# 將圖片插入 Ms Access

      C# Insert Picture into Ms Access(C# 將圖片插入 Ms Access)

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

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

                <bdo id='ZckbE'></bdo><ul id='ZckbE'></ul>
                <tfoot id='ZckbE'></tfoot>

                <legend id='ZckbE'><style id='ZckbE'><dir id='ZckbE'><q id='ZckbE'></q></dir></style></legend>

              • 本文介紹了C# 將圖片插入 Ms Access的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我要感謝所有在上一個問題中提供幫助的人.但現在,我對另一種說法有問題,即 saveimageto MS 訪問.首先我想問一下,在ms access數據庫上,Datatype應該放附件嗎?

                I would like to thanks to all who helped in last question. but now, i have problem with another statement which is saveimageto MS access. First, I would like to ask, on ms access database, Datatype should put attachment?

                我的代碼:

                private void button2_Click(object sender, EventArgs e)
                        {
                
                            OleDbCommand cmd = new OleDbCommand();
                            cmd.CommandType = CommandType.Text;
                            cmd.CommandText = "insert into Table1 (id,picture) values ('" + textBox1.Text +  "')";
                
                            cmd.Connection = con;
                            con.Open();
                            cmd.ExecuteNonQuery();
                            System.Windows.Forms.MessageBox.Show("Created", "Caption", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                            con.Close();
                
                        }
                

                我使用 openFIledialog 將我的圖片插入圖片框.

                I insert my picture to picturebox using openFIledialog.

                推薦答案

                首先,使用參數.永遠不要連接 SQL 命令的字符串,因為它會向 SQL 注入開放.這是一個易于遵循的良好做法,可以避免您將來遇到很多麻煩.

                First, use parameters. NEVER concat strings for SQL commands, as it opens itself to SQL Injection. That's an easy to follow good practice that'll avoid you a lot of trouble in the future.

                也就是說,這樣的事情應該可以工作:

                That said, something like this should work:

                // You've got the filename from the result of your OpenDialog operation
                var pic = File.ReadAllBytes(yourFileName);
                OleDbCommand cmd = new OleDbCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "insert into Table1 (id, picture) values (@p1, @p2)";
                cmd.Parameters.AddWithValue("@p1", TextBox1.Text);
                cmd.Parameters.AddWithValue("@p2", pic);
                cmd.ExecuteNonQuery();
                

                在這里從記憶中引用,但如果該代碼給您帶來麻煩,請告訴我.如果我沒記錯的話,應該可以這樣.

                Citing from memory here, but let me know if that code gives you trouble. If I remember correctly, something like that should work.

                EDIT.- 如果您在 PictureBox 控件上預加載圖像,將該圖像轉換為字節數組,然后將該字節數組用作第二個參數.

                EDIT.- If you're preloading the image on a PictureBox control, convert that image to a byte array and then use that byte array as the second parameter.

                編輯 (2).- 稍微澄清一下.如果您要從文件中獲取圖像,那么您就有了它的路徑;那么你可以使用 File.ReadAllBytes(string path).在我的示例中,我假設 yourFileName 是成功 OpenDialog 操作后所選文件的文件和路徑名.所以你可以這樣使用它:

                EDIT (2).- A little clarification. If you're are getting your image from a file, you have a path to it; then you can use File.ReadAllBytes(string path). In my example I was assuming that yourFileName was the file and path name of the selected file after a successful OpenDialog operation. So you can use it like this:

                byte[] fromPath = File.ReadAllBytes(@"C:wallsaurora.jpg");
                

                然后您將圖像存儲到字節數組 fromPath 中,轉換為字節并準備好在插入命令中使用,如上所示.

                and you'd store into the byte array fromPath the image, converted to bytes and ready to be used in an insertion command as seen above.

                但是如果您從圖片框控件獲取圖像,情況會有些不同:

                BUT if you're getting your image from a picture box control, things are a little different:

                MemoryStream ms = new MemoryStream();
                pictureBox1.Image.Save(ms, Imaging.ImageFormat.Jpeg);
                byte[] fromControl = ms.GetBuffer();
                

                在該示例中,我創建了一個 MemoryStream,用圖片框控件的內容填充它,然后將其傳遞給字節數組,我們再次準備將其用作參數用于我們的插入查詢.

                In that example I've created a MemoryStream, filled it with the content of the picturebox control and then passed it to the byte array, and again we're ready to use it as a parameter for our insertion query.

                哦,別忘了加

                using System.IO;
                using System.Drawing;
                

                到你的使用.

                這篇關于C# 將圖片插入 Ms Access的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                Calling A Button OnClick from a function(從函數調用按鈕 OnClick)

                  • <small id='SqxMo'></small><noframes id='SqxMo'>

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

                        1. <legend id='SqxMo'><style id='SqxMo'><dir id='SqxMo'><q id='SqxMo'></q></dir></style></legend>
                          主站蜘蛛池模板: 一级毛片视频 | 91极品尤物在线播放国产 | 狠狠色综合网站久久久久久久 | 亚洲国产一区二区视频 | 中文字幕欧美日韩 | 三级在线观看 | 久久久福利 | 天天操天天插 | 欧美日韩亚洲国产综合 | 粉嫩av久久一区二区三区 | 91精品久久久久久久久久 | 欧日韩在线观看 | 成人精品视频在线 | 自拍偷拍av | 青青草原综合久久大伊人精品 | 在线观看中文字幕 | 亚洲成人av | 久久福利 | 久久久久九九九女人毛片 | 中文精品一区二区 | 蜜桃在线播放 | 特黄色一级毛片 | 91免费在线视频 | av在线天堂网| 日韩一区二区三区精品 | 狠狠爱网址 | 欧美成人精品一区二区男人看 | heyzo在线 | 久久88| 超碰网址| 国产视频久久 | 欧美电影在线观看网站 | 中文字幕视频在线观看免费 | 欧美日韩在线一区二区三区 | 一本岛道一二三不卡区 | 不卡av电影在线播放 | 免费观看一级毛片 | 亚洲性综合网 | 国产精品久久久久久久久久久久午夜片 | 最新国产精品 | 精品久久久久一区二区国产 |