错误的味精参数无效 [英] Error msg parameter is not valid

查看:93
本文介绍了错误的味精参数无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍在尝试通过我的MS Access进入图片框显示图片.我的项目仅包含一个表单和一个图片框.每次我运行程序时,它会提示错误消息msg参数无效".这是我收到错误消息的地方.

myImage = Image.FromStream(myStream)

下面是我的代码.我需要帮助以显示此图像.谢谢.


I am still trying to display an image from my Ms Access to a Picture Box. my project contains only a form and a picturebox. Each time I run the program it prompt up an error msg " Parameter is not Valid ". This is where I get the Error Msg.

myImage = Image.FromStream(myStream)

Below is my Code. I am in need of assistance to get this image displayed. Thanks.


Imports System.Data.OleDb
Imports System.IO

Public Class Form1
    Dim myConnectionString As String
    Dim myConnection As OleDbConnection
    Dim myAdapter As OleDbDataAdapter
    Dim myDataset As DataSet

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        InitializeComponent()
        '' Code for Initialize ConnectionString
        myConnectionString = " Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Users\Bekesoft\Desktop\Programming\Pic Dbase.mdb"

        myConnection = New OleDbConnection(myConnectionString)
        Try
        Catch ex As Exception
        End Try

        myConnection.Open()
        myAdapter = New OleDbDataAdapter("SELECT Photograph FROM Picture", myConnection)
        myDataset = New DataSet
        myAdapter.Fill(myDataset)
        myConnection.Close()

        Dim myByte() As Byte = CType(myDataset.Tables(0).Rows(0)(0), Byte())

        Dim myImage As Image
        Dim myStream As New MemoryStream(myByte, 0, myByte.Length)
        myImage = Image.FromStream(myStream)

        PictureBox1.Image = Image.FromStream(myStream)


    End Sub

End Class

推荐答案

该错误表示您的字节数据不是有效的图像.最可能的原因是您一开始未能正确存储图像数据,或者您读取的数据错误.
The error means that your byte data is not a valid image. The most likely reason is that you failed to store your image data properly in the first place, or you''re reading the wrong data.


这篇关于错误的味精参数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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