Ronen,
I used the following code to talk to SQL Server's Northwind database.
Dim cmd As SqlCommand = cn.CreateCommand
cmd.CommandText = "select employeeid from employees where employeeid=10"
Dim i As Integer = cmd.ExecuteScalar()
MessageBox.Show(i)
EmplyeeID = 10 doesn't exist in the table so I got in the MessageBox the value of 0.
So in your case, not sure why you are getting this. What backend database are you using?
If you would like to know if any results are coming back or not then you shouldn't use the ExecuteScalar method. You should use the DataReader and then call the Read
property.
I hope this helps!
Thanks,
Hussein Abuthuraya
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.