www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with retrieving data from database syntax

  1. #1
    Join Date
    May 2011
    Location
    Wollongong, Australia
    Posts
    21

    Help with retrieving data from database syntax

    basically Im building a sales site that when you place an order it inputs it into a data base.
    I have made an admin page that views the orders in a grid view with the select option enabled.
    The problem im having is that I want to select the username from the orders then display in a text box the users address.

    This is the code I have
    Code:
     Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    
            Dim txtUserName As String
            Dim strGet As String
            
            txtUserName = GridView1.SelectedRow.Cells(3).Text()
            strGet = "select * from Security WHERE LogonId = '" & txtUserName & "'"
                    
            txtUser.Text = strGet
            
        End Sub


    I am thinking the problem is in this line

    Code:
    strGet = "select * from Security WHERE LogonId = '" & txtUserName & "'"

    Please help, im going nuts!!

  2. #2
    Join Date
    May 2011
    Location
    Wollongong, Australia
    Posts
    21
    After countless hours and lots of head bashing Problem solved!!
    I had to add
    Code:
    onselectedindexchanged="GridView1_SelectedIndexChanged"
    to the gridview
    and use
    Code:
    Dim daValidate As New OleDbDataAdapter(strGet, Conn)
            Dim dsValidate As New DataSet()
            
            daValidate.Fill(dsValidate, "dsItems")
            
            intRowNumber = 0
            
            Try
                txtUserDetails.Text = "User Name: " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("LogonId") & ControlChars.NewLine & "Name: " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("firstName") & " " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("lastName") & ControlChars.NewLine & "Address " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("houseNum") & " " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("streetName") & " " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("suburb") & " " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("state") & " " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("postCode") & ControlChars.NewLine & "Email: " & dsValidate.Tables("dsItems").Rows(intRowNumber).Item("email")
    Just in case anyone cared.. lol

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles