Imports MySql.Data.MySqlClient
Imports System.Data
Public Class frmMain
Dim strUser As String
Public Property _strUser() As String
Get
Return strUser
End Get
Set(ByVal value As String)
strUser = value
End Set
End Property
Public Sub LoadInfor()
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim dtAdapter As MySqlDataAdapter
Dim dt As New DataTable
Dim strConnString, strSQL As String
strConnString = "Server=localhost;User Id=root; Password=0000; Database=members; Pooling=false"
objConn.ConnectionString = strConnString
objConn.Open()
strSQL = "SELECT * FROM member WHERE Username = '" & strUser & "' "
dtAdapter = New MySqlDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
If dt.Rows.Count > 0 Then
Me.lblUser.Text = strUser
Me.lblName.Text = dt.Rows(0)("Name")
Me.lblEmail.Text = dt.Rows(0)("Email")
Me.lblAge.Text = dt.Rows(0)("Age")
Me.lblID.Text = dt.Rows(0)("CustomerID")
Me.lblGade.Text = dt.Rows(0)("Gade")
Me.lblWicha.Text = dt.Rows(0)("Wicha")
Me.lblClass.Text = dt.Rows(0)("Class")
Me.lblIdcard.Text = dt.Rows(0)("Idcard")
Me.lblRg.Text = dt.Rows(0)("Rg")
Me.lblNick.Text = dt.Rows(0)("Nick")
End If
objConn.Close()
objConn = Nothing
End Sub
Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
Dim frm As New frmLogin
frm.Show()
Me.Hide()
End Sub
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
sqlConn.Open()
Dim sql As New SqlDataAdapter("SELECT Picture FROM Pictures WHERE Pictures.CardID=5", sqlConn)
Dim ds1 As New DataSet()
sql.Fill(ds1, "Pictures")
Dim dr As DataRow = ds1.Tables("Pictures").Rows(0)
Dim result As Byte() = DirectCast(dr("Picture"), Byte())
Dim ArraySize As Integer = result.GetUpperBound(0)
Dim ms As New MemoryStream(result, 0, ArraySize)
pictureBox1.Image = Image.FromStream(ms)
sqlConn.Close()
Public Shared Function ByteArrayToImage(byteArrayIn As Byte()) As Image
Dim ms = New MemoryStream(byteArrayIn)
Dim returnImage As Image = Image.FromStream(ms)
Return returnImage
End Function
picBox.Image = ByteArrayToImage(dt.Rows(0)("Nick"))