how to retrieve multiple data from mysql to my windows application by a web service

Posted by Jerome under VB.NET on 4/18/2012 | Points: 10 | Views : 944 | Status : [Member] | Replies : 1
<WebMethod()> _
Public Function viewpic(ByVal kyc As String) As clsloan
GetINI()
Dim dal As New DAL.DataAccess
Dim dr As MySqlDataReader
Dim cls As New clsloan
Try
dal.ConnectionString = ls_connectionString
dal.Provider = EnumProviders.MySQL

Dim str As String = "select kycno,afilename,picfile from nclattachments where kycno = '" & kyc & "'"
dr = dal.ExecReader(str, CommandType.Text)

While dr.Read
Dim lb As Byte() = CType(dr.Item("picfile"), Byte())
Dim filename As String = dr.Item("afilename")
cls.filename = filename
cls.picfile = lb

End While
Catch ex As Exception
MsgBox(ex.Message, "Error Message")
End Try
Return cls
End Function


I have this code above It works fine but it only return the last file.How could I access the first file to the last which will b placed in a listview im application.




Responses

Posted by: Thiru on: 4/18/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Use Adapter to fill dataset
<WebMethod()> _ 

Public Function viewpic(ByVal kyc As String) As clsloan
GetINI()
Dim dal As New DAL.DataAccess
Dim cmd as mysqlcommand
Dim adp as mysqldataadapter
Dim ds as new dataset
Dim dr As MySqlDataReader
Dim cls As New clsloan
Try
dal.ConnectionString = ls_connectionString
dal.Provider = EnumProviders.MySQL

Dim str As String = "select kycno,afilename,picfile from nclattachments where kycno = '" & kyc & "'"
cmd=new mysqlcommand(str,<connection>)
adp=new mysqldataadapter(cmd)
adp.fill(ds)
return ds
Catch ex As Exception
MsgBox(ex.Message, "Error Message")
End Try
Return cls
End Function



Jerome, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response