Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

executescalar error

$
0
0

how to use executescalar........

i m using this code.

string connstr = @"Server=.\SQLEXPRESS ;Initial Catalog=ABJDATABASE;Integrated Security=True; Max Pool Size=100";
            string query = "SELECT SUM(txtWeight) AS txtWeight FROM personalData";
            SqlConnection conn = new SqlConnection(connstr);
            conn.Open();

            SqlCommand myCommand = new SqlCommand(query, conn);
            txtTotalWeight.Text = (string)myCommand.ExecuteScalar();
            conn.Close();

it gives a error

Unable to cast object of type 'System.Double' to type 'System.String'.


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>