Select/ Sum Statement In Visual Basic-VBForums
Results 1 to 3 of 3

Thread: Select/ Sum Statement In Visual Basic

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    47

    Select/ Sum Statement In Visual Basic

    I have in select statement, which retrieve all data from a SQL Table. But what im trying to get the select statment to do is, sort the data, in group them. In give a sum of the same data. I will need this in a select statment. Can someone please help?



    Public Class Inventory_Summary
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim cnn As SqlConnection
    Dim connectionString As String
    Dim sql As String

    connectionString = "Server=10.53.252.221;UID=phasqladmin;PWD=i82dothis;Database=phabsproduction;Integrated Security=False"
    cnn = New SqlConnection(connectionString)
    cnn.Open()
    sql = "Select * from YF_Safety_Stock_Inventory"
    Dim dscmd As New SqlDataAdapter(sql, cnn)
    Dim ds As New DataSet
    dscmd.Fill(ds)
    DataGridView1.DataSource = ds.Tables(0)
    cnn.Close()
    Exit Sub
    End Sub

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,601

    Re: Select/ Sum Statement In Visual Basic

    The SQL code is nothing to do with VB.NET. SQL is SQL. The VB.NET code is the same no matter what the SQL code looks like, so this is not a VB.NET question. SQL questions belong in the Database Development forum. As such, I'm going to ask the mods to move this thread.

    As for the question, you haven't give enough detail. Sort by what? Group by what? Sum what?

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    37,192

    Re: Select/ Sum Statement In Visual Basic

    Thread moved to the 'Database Development' forum - which is where you should always post SQL questions (while SQL can be used in VB, it is certainly not specific to VB)

    (thanks for letting us know jmcilhinney )

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.