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
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?
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 :thumb: )