16,553
社区成员
发帖
与我相关
我的任务
分享
Private Sub BindData()
Try
Dim sql As String = "select ID as '编号',Name as '姓名',Sex as '性别',TypeName as '分组',Birthday as '生日',TEL as '联系方式',Photo as '照片' from PIInfo"
Dim dt As DataTable = GetDataTable(sql)
If dt.Rows.Count <> 0 Then
DataGrid1.DataSource = dt
End If
Catch ex As Exception
WriteErr(ex)
End Try
End Sub
Private Sub bindTextBox(ByVal row As Int16)
Me.TxtID.Text = Me.DataGrid1.Item(row, 0)
Me.TxtName.Text = Me.DataGrid1.Item(row, 1)
Me.CmbSex.Text = Me.DataGrid1.Item(row, 2)
Me.CmbType.Text = Me.DataGrid1.Item(row, 3)
Me.DateBir.Value = Me.DataGrid1.Item(row, 4)
Me.TxtTLE.Text = Me.DataGrid1.Item(row, 5)
Me.PhotoPath.Text = ""
Dim MyData() As Byte = Me.DataGrid1.Item(row, 6) '提示错误在这里
Dim Photo As New MemoryStream(MyData)
PictureBox1.Image = Image.FromStream(Photo)
End Sub
Public Function GetDataTable(ByVal sql As String) As DataTable
Dim dt As New DataTable
Try
Sqlcon.Open()
Dim SqlAda As New SqlDataAdapter(sql, Sqlcon)
SqlAda.Fill(dt)
Catch ex As Exception
WriteErr(ex)
Finally
Sqlcon.Close()
End Try
Return dt
End Function