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

                問題描述

                限時(shí)送ChatGPT賬號..

                我要感謝所有在上一個(gè)問題中提供幫助的人.但現(xiàn)在,我對另一種說法有問題,即 saveimageto MS 訪問.首先我想問一下,在ms access數(shù)據(jù)庫上,Datatype應(yīng)該放附件嗎?

                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.

                推薦答案

                首先,使用參數(shù).永遠(yuǎn)不要連接 SQL 命令的字符串,因?yàn)樗鼤?huì)向 SQL 注入開放.這是一個(gè)易于遵循的良好做法,可以避免您將來遇到很多麻煩.

                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.

                也就是說,這樣的事情應(yīng)該可以工作:

                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();
                

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

                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 控件上預(yù)加載圖像,將該圖像轉(zhuǎn)換為字節(jié)數(shù)組,然后將該字節(jié)數(shù)組用作第二個(gè)參數(shù).

                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).在我的示例中,我假設(shè) 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");
                

                然后您將圖像存儲到字節(jié)數(shù)組 fromPath 中,轉(zhuǎn)換為字節(jié)并準(zhǔn)備好在插入命令中使用,如上所示.

                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.

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

                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();
                

                在該示例中,我創(chuàng)建了一個(gè) MemoryStream,用圖片框控件的內(nèi)容填充它,然后將其傳遞給字節(jié)數(shù)組,我們再次準(zhǔn)備將其用作參數(shù)用于我們的插入查詢.

                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;
                

                到你的使用.

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

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

                相關(guān)文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運(yùn)行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時(shí)刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時(shí)突出顯示行)
                Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 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| 91精品在线看 | 国产精品中文字幕在线播放 | 欧美国产日韩在线观看 | 超碰精品在线 | 在线色网站 | 久久久女 | 午夜影院在线观看 | 国产精品一区二区三区在线 | 免费观看羞羞视频网站 | 久久国产精品一区二区三区 | 91精品国产91久久久久久丝袜 | 视频一二区 | 亚洲一区免费视频 | 国产一区二区在线免费观看 | 91亚洲精选 | 亚洲国产欧美日韩 | 亚洲精彩视频在线观看 | 99久久中文字幕三级久久日本 | 免费观看www7722午夜电影 | 日本特黄a级高清免费大片 特黄色一级毛片 | 午夜成人免费视频 | 国产精品精品视频一区二区三区 | 欧美日韩一区不卡 | 亚州精品天堂中文字幕 | 国产精品99久久久久久人 | 人人鲁人人莫人人爱精品 | 日韩在线免费播放 | 国产精品美女 | 欧美一级电影免费 | 一区二区三区视频在线 | 自拍视频一区二区三区 | 国产精品中文字幕在线观看 |