Results 1 to 3 of 3

Thread: [2008] Returning/displaying multiple rows from SQL database

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    4

    [2008] Returning/displaying multiple rows from SQL database

    Hello there,

    I have a program that calculates several different Maths functions. There is an SQL database on the back-end which records the name of the user, the name of the math function they use, and the date.

    I would like to return and display all of the rows where one particular username is featured. So, if a user has used the system 5 times, 5 rows could be displayed in a datagrid on my form.

    I understand that I need to make the SQL connection, use the correct SQL statement, and use an Data Adapter to hold the data and then put it into a dataset. Thing is, I have no idea how to do this!

    Don't suppose anyone could shed any light on this?

    SQL code I have so far is: (its being hosted by WCF)

    Code:
    Public Function DatabaseSearch(ByVal UserName As String) As Boolean Implements SearchServiceContract.DatabaseSearch
            Dim connection As SqlConnection
            Dim command As SqlCommand
            Dim query As String
            Dim connStringBuild As New SqlConnectionStringBuilder
    
            Try
                connStringBuild.DataSource = "BUSDEV"
                connStringBuild.InitialCatalog = "Northwind"
                connStringBuild.UserID = "vbasic"
                connStringBuild.Password = "*******"
    
                query = "SELECT * FROM WCFTrigNP WHERE username = '" & UserName & "'"
                connection = New SqlConnection(connStringBuild.ConnectionString)
                command = New SqlCommand(query, connection)
    
    
                connection.Open()
                command.ExecuteNonQuery()
    
            Catch ex As Exception
                Return False
    
            End Try
    
            Return True
        End Function
    Thanks guys

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [2008] Returning/displaying multiple rows from SQL database


  3. #3

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    4

    Re: [2008] Returning/displaying multiple rows from SQL database

    Thanks, both of those look pretty much what I need, and I'll have a go at implementing them.

    In the meantime, if anybody has the actual code required, I'd be happy to see it!

    Cheers

Posting Permissions

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



Click Here to Expand Forum to Full Width