Sql query

Jul 27 2013 2:58 AM
 Dim constring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\appln\appln\Acc.accdb"
        Dim insertcmd As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand
        Dim con As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection
        con.ConnectionString = constring
        insertcmd.CommandType = CommandType.Text
        insertcmd.CommandText = String.Format("select sum(total) from account where ID between {0} and {1}", TextBox1.Text, TextBox2.Text)
        insertcmd.Connection = con
        con.Open()
        Try
            insertcmd.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

        con.Close()
this is code i am using but i dnt know how to get total from database ...


Answers (13)