Select data from database and display in textbox

tiffany

Well-known member
Joined
Aug 7, 2005
Messages
57
Programming Experience
1-3
Hi, i'm having a porb on how to select the data from database and display in the textbox. i had use the sql like this to select the data:

Public Function displayEditMsg(ByVal userName As String, ByVal strname As String) As Dataset
Dim ds As New DataSet
Dim da As New SqlDataAdapter("SELECT msg, Member.userName, Member.dt FROM msg, Member WHERE msg.username = '" & strname & "'AND Member.userName = msg.userName", cn)
cn.Open()
da.Fill(ds)
cn.Close()
Return ds
End Function


I use this code to display the datas in the textbox:

Dim userName As String
Dim strname As String = user_name.Text
tb_msg.Text = bl.displayEditMsg(userName, strname).ToString

Can anyone help me with it? With these codes, the datas can't be display.

thankx
tiffany
 
I had try another method to do it but it still not perfectly done. I use Session to select from the datagrid then display in the textboxes in the nest webform.

'This is the datagrid where i need to retrieve the data from here. In adata cell i had contain more then 1 dataitem.
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand

If btn.Text = "Edit/Delete" Then

Dim aTopic As String
Session("aTopic") = lb_topic.Text
Dim aCat As String
Session("aCat") = lk_cat.Text
Dim aSubCat As String
Session("aSubCat") = lk_subCat.Text

Session("name") = ds.Tables(0).Rows(0)("userName")
Session("dat") = ds.Tables(0).Rows(0)("dt")
Session("msg") = ds.Tables(0).Rows(0)("msg")

Response.Redirect("FDelEdit.aspx")
End If

End Sub

'This is the page load where data are being display in the textboxes
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

lb_topic.Text = Session("aTopic")
lk_cat.Text = Session("aCat")
lk_subCat.Text = Session("aSubCat")

lb_name.Text = Session("name")
lb_dt.Text = Session("dat")
tb_msg.Text = Session("msg")
End Sub


But when i use those codes, it only retrieve the first row of the datas whenever i had clicked the button for other rows. Can anyone help me in this?

Thanks
tiffany

 
Back
Top