I am new to vb.net i want to display images.but the problem is navigation code is improper.pls help me.
Public Sub showimage()
On Error GoTo fix
Dim sql As String = "SELECT CUST_IMAGE FROM form2 WHERE FULL_NAME='" & Label2.Text & "'"
DBcon.Open()
Dim cmd As OleDbCommand = New OleDbCommand(sql, DBcon)
Dim b() As Byte
b = cmd.ExecuteScalar()
If (b.Length > 0) Then
Dim stream As New MemoryStream(b, True)
stream.Write(b, 0, b.Length)
'Display image
PictureBox1.Image = New Bitmap(stream)
stream.Close()
End If
DBcon.Close()
fix:
Exit Sub
End Sub
Navigating images code
Dim DBcon As OleDb.OleDbConnection
Dim Dbcom As New OleDb.OleDbCommand()
Dim Dbadap As New OleDb.OleDbDataAdapter()
Dim Dbset As New DataSet()
Dim Nextb As Long
Dim PrevB As Long
Dim TotalC As Long
Public Sub ShowData()
Nextb = 0
PrevB = 0
Dim STrPath = System.IO.Directory.GetCurrentDirectory & "\MMTS_DB.mdb"
Try
DBcon = New OleDbConnection("Provider=microsoft.jet.oledb.4.0;data source=" & Application.StartupPath & "\MMTS_DB.mdb;jet oledb:database password=Kaila@123")
Dbcom = New OleDbCommand("Select FULL_NAME,CUST_IMAGE from form2 where CUST_ID <>null order by CUST_ID asc")
DBcon.Open()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "MMTS Project Connection")
End
End Try
Dbcom.Connection = DBcon
Dbadap = New OleDb.OleDbDataAdapter("Select FULL_NAME,CUST_IMAGE from form2 where CUST_ID <>null order by CUST_ID asc", DBcon)
Dbset = New DataSet("MS")
Dbadap.Fill(Dbset, "MS")
Dim x = Dbset.Tables("MS").Rows.Count()
TotalC = x - 1
FILL(0)
DBcon.Close()
End Sub
Private Sub FILL(ByVal X As Long)
If Dbset Is Nothing Then Return
Try
With Dbset.Tables("MS").Rows(X)
Label2.Text = IIf(IsDBNull(.Item("FULL_NAME")), "NULL", .Item("FULL_NAME"))
showimage()
End With
Catch err As Exception
MsgBox(err.Message, MsgBoxStyle.Information, "MMTS PROJECT Dataset")
End Try
End Sub
Admin Edit: Please use code tags when posting your code. Code tags are used like so =>
Thanks,
PsychoCoder

New Topic/Question
Reply




MultiQuote



|