- 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
0
votes
3 answers
ExecuteScalar null value error
This is my code..
object o = DBExecuteScalar(myQuery);
if ((int.parse(o.ToString())) <= 2 || (o is null))
{
// my task....
}
In this code, 'o is null' part is giving error. Any help how to deal with these both conditions in…

user3563084
- 11
- 1
- 5
0
votes
1 answer
More than one session created to view data of an individual
I'm trying to make so many session in order to retrieve information of an individual for whom session is created inside my website. for now the execute scalar gives me just one value for all the labels i have assigned to different sessions created…

user3447076
- 25
- 7
0
votes
0 answers
Data type mismatch in criteria expression with execute scalar method only with alpha characters as parameter, number ok
Not sure Why I get the unhandled exception mentioned above. If this is executed with a number in the textbox, its fine, but any alpha character, and it throws the exception.
Dim Unumber As String = TextBox_U_Number.Text
Dim con As…
0
votes
2 answers
input string was not in correct format
i have a webforms app using asp/C# .net with SQL server 2008.
i have a login form that will authenticate access to my webform website.
here is the code.
SqlConnection an = new SqlConnection(@"Data Source=REZRTECH\SQLEXPRESS;Initial…

REZR.AMX
- 59
- 5
- 20
0
votes
1 answer
SELECT CASE to ExecuteScalar()
I'm trying to insert new records into a table. The first field in the table is an supposed to be an autonumber, even though it isn't at the moment, and I am trying to run ExecuteScalar() to retrieve the MAX of that field (ELECT_BONUS_DFRL_SEQ_ID, if…

Mark C.
- 6,332
- 4
- 35
- 71
0
votes
2 answers
ExecuteScalar multiple transactions
I am trying to execute ExecuteScalar() with 2 instruction with ODBC connection to mysql in a query. My query is :
string query = @"SET @MY_ID := (SELECT IFNULL(MAX(id) + 1, 1) FROM sc);" + Environment.NewLine + "INSERT INTO sc (id, name) values…

user3346290
- 53
- 1
- 5
0
votes
3 answers
Getting single response from SQL Server stored procedure with C#
I've been wrestling with this for several days and have extensively dug through StackOverflow and various other sites. I'm literally drawing a blank. I'm trying to get a single result back from my stored procedure.
Here's my stored…

Tim
- 57
- 1
- 8
0
votes
1 answer
Visual Basic Login
Would somebody be able to help me I'm having some issues with my login.
When i try to log in i get the error "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." - In junction with the…

Jaxom Nutt
- 49
- 1
- 7
0
votes
1 answer
How to execute sql scripts from a staging table in sql stored procedure
What are the best approaches to the below scenario?
In my C# program, I have some sql commands such as UPDATE, INSERT, DELETE. I could execute them in my C# program (which works fine) but I need to execute these sql commands when one of the stored…

Anirudh
- 581
- 5
- 14
- 32
0
votes
4 answers
SQL function returns Wrong in c#
I have a function in SQL which returns right answer when execute in SQL Managment
this is my Function
ALTER FUNCTION [dbo].[Dore1]
(@First NVARCHAR(50), @second NVARCHAR(50))
RETURNS INT
AS
BEGIN
DECLARE @Tedad INT
SET @tedad =…

Shaghayegh
- 1
- 1
0
votes
1 answer
Casting from ExecuteScalar on OleDbCommand in C#
I am receiving the following error from my code:
The following errors occurred:
System.Data.OleDb.OleDbException (0x80040E07): Data type mismatch in criteria expression.
at…

Coder787
- 1
- 1
- 1
0
votes
1 answer
SPROC insert with ExecuteNonQuery and ExecuteScalar
SQL insert issue. Running a stored procedure to insert rows to a table and returning the ID created. WHen I run it like this and have an output parameter @ID and use ExecuteNonQuery() it returns -1 for my int idinserted but does give me back the ID…

Jt2ouan
- 1,964
- 9
- 33
- 55
0
votes
1 answer
Errors for SQL Server connection in asp server
In an asp server we are getting error for SQL Server after executing ExecuteScalar, ExecuteReader and ExecuteNonQuery like shown below. The error will only come sometimes, it's not seen always. So anyone know why does this error comes? How to solve…

IT researcher
- 3,274
- 17
- 79
- 143
0
votes
1 answer
Exception in use ExecuteScalar
I want to get a person from database in C# with ADO.net.
I use this command:
System.Data.Common.DbCommand command = DatabaseManager.Database.GetStoredProcCommand(proc_name, firstName);
and then
object personID =…

Tavousi
- 14,848
- 18
- 51
- 70
0
votes
1 answer
LINQ to Entities Select New
public static object ExecuteScalar(string SQL)
{
try
{
var A = new EGModel.EGEntity().Connection;
var command = ((EntityConnection)(A)).StoreConnection.CreateCommand();
command.CommandType =…
user1092280