Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all i have created small mobile application, in my mobiel application i have connection class file where i am connecting to my application to database and
excuting insert query, i am reteriving data's from sql using sqlcedatareader,now i have my collection of data's in sqlcedatareader
how i ll assign the data's to my text box control from the sqlcedatareader
note my sqlcedatareader is in class file, text box control in form
Posted

1 solution

Depends on how the connection class file returns that data.

As far as the text box is concerned , it is nothing out of the ordinary:
VB
myTextBox.Text = stringFromSomewhere

If your class file is returning the SqlDataReader (and that would be a reasonably bad idea - they should be disposed, and it is normally the responsibility of the creator to call Dispose when needed) then just access that and move it:
VB
If reader.Read() Then
	Dim desc As String = DirectCast(reader("description"), String)
	myTextBox.Text = desc
End If
If it doesn't, then we would need to know what it does return to give you a more detailed answer.
 
Share this answer
 
Comments
sameertm 25-Mar-12 11:04am    
this is my connection class file

Public Function OpenRs(ByVal StrSql As String) As SqlDataReader
Public con1 As SqlCeConnection
con1 = New SqlCeConnection(sdf_connectionstring)
Dim cmd As New SqlCeCommand(StrSql, con1)
cmd.Connection = con1
OpenRs1 = cmd.ExecuteReader()
End Function
now i have all my data's into OpenRs1
from OpenRs1 ,how i ll get my reterived data from OpenRs1 to my form code window
OriginalGriff 25-Mar-12 12:25pm    
You could return the OpenRs1 reader from the method and use it as "reader" in my example.
However, I would read them in the OpenRs method, and return a class or a List of class holding the values.
That way the layer above is more independent of the data source. If you return an SqlDataReader or an SqlCeDataReader then you "fix" what the layer above can refer to.
sameertm 26-Mar-12 3:16am    
thanks it works out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900