Sub Add() cmdStr = "SELECT [col3] FROM [table1];" End Select i = 0 connStr = "server=myServer;initial catalog=myDB;uid=myID;pwd=myPassword" Using conn As New SqlConnection(connStr) conn.Open() Using cmd As New SqlCommand(cmdStr, conn) Using dr As SqlDataReader = cmd.ExecuteReader() While dr.Read() count = count + dr(i) i = i + 1 End While End Using End Using End Using TextBox2.Text = count End Sub
cmdStr
cmdStr = "SELECT SUM(col3) FROM table1"
dr.GetInt...
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)