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

Thread: Select/ Sum Statement In Visual Basic

  1. #1

    Thread Starter
    Join Date
    Jun 2012

    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=;UID=phasqladmin;PWD=i82dothis;Database=phabsproduction;Integrated Security=False"
    cnn = New SqlConnection(connectionString)
    sql = "Select * from YF_Safety_Stock_Inventory"
    Dim dscmd As New SqlDataAdapter(sql, cnn)
    Dim ds As New DataSet
    DataGridView1.DataSource = ds.Tables(0)
    Exit Sub
    End Sub

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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

    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


Click Here to Expand Forum to Full Width