访问2007/2010错误或什么? [英] Access 2007/2010 Bugs or What?

查看:69
本文介绍了访问2007/2010错误或什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..我学习了如何使用VB.Net制作数据库程序,并使用Access 2010(accdb扩展名)作为数据库. tbl_students中的字段之一是OLE对象,用于保存图像.每次插入图像(使用SQL语句和MemoryStream)时,程序都会立即关闭.因此,我使用Access 2003格式(mdb扩展名)代替Access 2010,并且运行良好.我的问题是;将图像另存为Ole对象是否是Access 2007/2010中的错误?
注意:我的代码在sql Server 2005和Access 2003中都经过了良好的测试,没有任何问题.仅当我使用Access 2007/2010时才会出现此问题.谢谢.

Hi.. I learn how to make database program using VB.Net and I use access 2010 (accdb extension) as my database. One of the field in tbl_students is OLE Object where it saves images. Every time I insert an image (using SQL Statement and MemoryStream) the program closes itself immediately. So, instead of access 2010 I use access 2003 format (mdb extension) and it runs well. My question is; Is it a bug in access 2007/2010 to save images as Ole Object??
Note: My code is well tested in sql server 2005 and access 2003 and there''s no single problem. The problem appears only when I use access 2007/2010. Thank you.

Private Sub SaveDataImage
    Dim sqlSaveImage As String = "INSERT INTO tblpasien VALUES(@no,@nama,@alamat,@usia,@kelamin,@gambar)"
        Try
            Dim OdbCommand As OleDbCommand = New OleDbCommand(sqlSaveImage,Koneksi)
            If isTextEmpty(Me) = False  Then ''<-- This is my own sub procedure
                With OdbCommand.Parameters
                    .AddWithValue("@no",txtNoPasien.Text)
                    .AddWithValue("@nama",txtNama.Text)
                    .AddWithValue("@alamat",txtAlamat.Text)
                    .AddWithValue("@usia",txtUsia.Text)
                    .AddWithValue("@kelamin", cmbKelamin.Text)
                End With

                Dim StreamImage As New MemoryStream()
                PictureBox1.Image.Save(StreamImage, PictureBox1.Image.RawFormat)
                Dim BufferImage As byte() = StreamImage.GetBuffer 
                OdbCommand.Parameters.AddWithValue("@gambar", SqlDbType.Image).Value = BufferImage

                ''Execution
                Koneksi.Open 
                OdbCommand.ExecuteNonQuery
                Koneksi.Close 

                ''Clear text
                ClearAllText(Me)
                txtNoPasien.Focus 

                ''Show in grid after saving
                mdlConnection.ShowPatientsGrid(DGPatients)
                GridPlan

                ''pict variable must be empty after execution
                pict = String.Empty 
                Me.PictureBox1.Image = My.Resources.Label
            Else
                MsgBox("Entri data kosong",vbInformation)
                pict = String.Empty
                Exit Sub
            End if
            
        Catch ex As Exception
            Koneksi.Close 
            MsgBox("Tidak bisa menyimpan data. Terdapat kesalahan penulisan",vbExclamation)
        End Try

End Sub

推荐答案

没有看到添加此数据的代码,就不可能告诉您哪里出了问题.

不,将图像插入Access 2007/2010数据库没有任何错误.
Without seeing your code that is adding this data, it''s impossible to tell you where you went wrong.

No, there is no bug with inserting images into an Access 2007/2010 database.


这篇关于访问2007/2010错误或什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆