- Executes a query, and returns the first column of the first row in the query-result set. - Additional columns and rows are ignored.
Questions tagged [executescalar]
153 questions
-3
votes
1 answer
ExecuteScalar requires an open and available Connection. The connection's current state is closed
When trying to register a new account in my program, via the LocalDB, I get an error stating:
ExecuteNonQuery requires an open and available Connection. The connection's current state is closed
But as you can see, I am opening the connection…

Mr F
- 33
- 1
- 1
- 5
-3
votes
3 answers
"There was an error parsing the query."
I have the following code to check a user:
private void button1_Click(object sender, EventArgs e)
{
string ss = "SElECT * FROM 123 WHERE u=@USERNAME";
using (SqlCeConnection cn = new SqlCeConnection(@"Data…

kipo
- 63
- 1
- 1
- 6
-3
votes
1 answer
ExecuteScalar can return null?
I have a query : "Select IsNull(ItemBarcode,0) From Items where ItemID = 12313"
If in my database, 12312 ID does not exist on my table, then what will ".NET ExecuteScalar" return to me (If I assign it to an object variable?
private Object Result…

ahmet
- 702
- 1
- 10
- 29