Vb.net 如何使用数据和图像存储在sqlserver表中的数据填充datagridview
我看过很多关于这个问题的文章。但是没有得到正确的答案,或者可能是我无法理解 我有一个表,它将收据编号、批号和收据副本作为图像存储在数据库中 对于ex:Referenceid:int 批次号:int 接收压缩:图像 我正在尝试在datagridview中显示此数据Vb.net 如何使用数据和图像存储在sqlserver表中的数据填充datagridview,vb.net,datagridview,populate,Vb.net,Datagridview,Populate,我看过很多关于这个问题的文章。但是没有得到正确的答案,或者可能是我无法理解 我有一个表,它将收据编号、批号和收据副本作为图像存储在数据库中 对于ex:Referenceid:int 批次号:int 接收压缩:图像 我正在尝试在datagridview中显示此数据 Dim sqlString As String Dim storeID As String Dim saleDate As String Dim ds As DataSet With DataGridView1 s
Dim sqlString As String
Dim storeID As String
Dim saleDate As String
Dim ds As DataSet
With DataGridView1
storeID = .CurrentRow.Cells(1).Value
saleDate = .CurrentRow.Cells(2).Value
End With
sqlString = "select batchnumber, [time],ReceiptCompressed from Journal where TransactionType=16 and StoreId ='" & storeID & "'" & _
" and [Time] between '" & saleDate & " 00:00:00' and '" & saleDate & " 23:59:59'"
ds = getDataset(connectionString, sqlString)
DataGridView2.DataSource = ds.Tables(0)
问题是加载数据时出现错误
“datagridview中发生以下错误
Dim sqlString As String
Dim storeID As String
Dim saleDate As String
Dim ds As DataSet
With DataGridView1
storeID = .CurrentRow.Cells(1).Value
saleDate = .CurrentRow.Cells(2).Value
End With
sqlString = "select batchnumber, [time],ReceiptCompressed from Journal where TransactionType=16 and StoreId ='" & storeID & "'" & _
" and [Time] between '" & saleDate & " 00:00:00' and '" & saleDate & " 23:59:59'"
ds = getDataset(connectionString, sqlString)
DataGridView2.DataSource = ds.Tables(0)
system.argumentexception.image.fromstream(系统系统、boolean useembeddedcolormanagement、boolean validateimagedata”等)
有人能告诉我最简单的方法是什么吗?正如前面提到的存储在表中的数据,我希望将其与图像一起加载到datagridview中
谢谢
Venkat尝试将图像保存为base64字符串:
Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(strTextOrFile)
strModified = Convert.ToBase64String(byt)
…并将其保存到数据库中。要将base64字符串转换为图像,请使用:
Dim b As Byte() = Convert.FromBase64String(strModified)
strTextOrFile = System.Text.Encoding.UTF8.GetString(b)
处理图像的另一种方法是不将图像保存到数据库中,而只保存其路径。图像是一种格式吗?我有一个应用程序将pos收据存储在数据库中。比较X报告(日终)是一项繁琐的活动和实际销售报告。我正在尝试创建一个应用程序,在选择日期和门店名称时显示来自数据库的X报告并显示在图片框中。这为用户节省了大量时间。我不明白的是为什么“参数无效”生成错误。sql server数据库中字段的数据类型为“image”,并遵循web中的相同示例。可能与您使用的基本语言(以及您的实际编码)有关。出现错误时,您是否可以发布一些正在使用的值?