Hi,
I have a problem with SqlHelper.ExecuteScalar ...
When I try to execute SqlHelper.ExecuteScalar I get this message:
"System.InvalidCastException: Object must implement IConvertible.".
Help ...
Thanx, Neven
----------------------
SqlParameter[] arrSqlParam = null;
arrSqlParam =
SqlHelperParameterCache.GetSpParameterSet(DB.getCo nnectiongString(),
"GetFullUserName");
arrSqlParam[0].Value = strUserName;
strFullUserName = Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(),
"GetFullUserName", arrSqlParam);
------------------------
CREATE PROCEDURE GetFullUserName
@strUserName nvarchar(50),
@strUserNameFull nvarchar(100) OUT
AS
SET @strUserNameFull = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
[tblUsers].[user_name] = @strUserName)
GO 7 11986
ExecuteScalar returns a Object type..you should cast this object to a string
like so:
strFullUserName = (string)
Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(),
"GetFullUserName", arrSqlParam);
"Neven Klofutar" wrote: Hi,
I have a problem with SqlHelper.ExecuteScalar ...
When I try to execute SqlHelper.ExecuteScalar I get this message: "System.InvalidCastException: Object must implement IConvertible.".
Help ...
Thanx, Neven
---------------------- SqlParameter[] arrSqlParam = null; arrSqlParam = SqlHelperParameterCache.GetSpParameterSet(DB.getCo nnectiongString(), "GetFullUserName"); arrSqlParam[0].Value = strUserName;
strFullUserName = Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(), "GetFullUserName", arrSqlParam);
------------------------ CREATE PROCEDURE GetFullUserName @strUserName nvarchar(50), @strUserNameFull nvarchar(100) OUT AS
SET @strUserNameFull = (SELECT ime + ' ' + prezime FROM tblUsers WHERE [tblUsers].[user_name] = @strUserName) GO
It's not that, I still get an error, I also tried this:
strFullUserName =
Convert.ToString(Utility.SqlHelper.ExecuteScalar(U tility.DB.getConnectiongSt
ring(), "GetFullUserName", arrSqlParam));
"Tampa .NET Koder" <Ta***********@discussions.microsoft.com> wrote in
message news:C3**********************************@microsof t.com... ExecuteScalar returns a Object type..you should cast this object to a
string like so:
strFullUserName = (string) Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(), "GetFullUserName", arrSqlParam);
"Neven Klofutar" wrote:
Hi,
I have a problem with SqlHelper.ExecuteScalar ...
When I try to execute SqlHelper.ExecuteScalar I get this message: "System.InvalidCastException: Object must implement IConvertible.".
Help ...
Thanx, Neven
---------------------- SqlParameter[] arrSqlParam = null; arrSqlParam = SqlHelperParameterCache.GetSpParameterSet(DB.getCo nnectiongString(), "GetFullUserName"); arrSqlParam[0].Value = strUserName;
strFullUserName =
Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(), "GetFullUserName", arrSqlParam);
------------------------ CREATE PROCEDURE GetFullUserName @strUserName nvarchar(50), @strUserNameFull nvarchar(100) OUT AS
SET @strUserNameFull = (SELECT ime + ' ' + prezime FROM tblUsers WHERE [tblUsers].[user_name] = @strUserName) GO
Utility.SqlHelper ... is not an error, I put it in my library ...
Neven strFullUserName =
Convert.ToString(Utility.SqlHelper.ExecuteScalar(U tility.DB.getConnectiongSt ring(), "GetFullUserName", arrSqlParam));
"Tampa .NET Koder" <Ta***********@discussions.microsoft.com> wrote in message news:C3**********************************@microsof t.com... ExecuteScalar returns a Object type..you should cast this object to a string like so:
strFullUserName = (string) Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(), "GetFullUserName", arrSqlParam);
"Neven Klofutar" wrote:
Hi,
I have a problem with SqlHelper.ExecuteScalar ...
When I try to execute SqlHelper.ExecuteScalar I get this message: "System.InvalidCastException: Object must implement IConvertible.".
Help ...
Thanx, Neven
---------------------- SqlParameter[] arrSqlParam = null; arrSqlParam = SqlHelperParameterCache.GetSpParameterSet(DB.getCo nnectiongString(), "GetFullUserName"); arrSqlParam[0].Value = strUserName;
strFullUserName = Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(), "GetFullUserName", arrSqlParam);
------------------------ CREATE PROCEDURE GetFullUserName @strUserName nvarchar(50), @strUserNameFull nvarchar(100) OUT AS
SET @strUserNameFull = (SELECT ime + ' ' + prezime FROM tblUsers WHERE [tblUsers].[user_name] = @strUserName) GO
"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message
news:en**************@TK2MSFTNGP15.phx.gbl... Hi,
I have a problem with SqlHelper.ExecuteScalar ...
Confusingly, ExecuteScalar is for commands which return result sets.
You want ExecuteNonQuery, and then examine the parameter.
David
you sp has no result set, so execute scaler is returning an error. execute
scalre returns the first column of the first result set. if there is no
result set, then its stuck.
change you proc to return the name in a result set, or use ExecuteNoQuery,
and get the value from the sp parameter (which must be declared an out in
your code to work).
-- bruce (sqlwork.com)
"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message
news:en**************@TK2MSFTNGP15.phx.gbl...
| Hi,
|
| I have a problem with SqlHelper.ExecuteScalar ...
|
| When I try to execute SqlHelper.ExecuteScalar I get this message:
| "System.InvalidCastException: Object must implement IConvertible.".
|
| Help ...
|
| Thanx, Neven
|
| ----------------------
| SqlParameter[] arrSqlParam = null;
| arrSqlParam =
| SqlHelperParameterCache.GetSpParameterSet(DB.getCo nnectiongString(),
| "GetFullUserName");
| arrSqlParam[0].Value = strUserName;
|
| strFullUserName =
Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(),
| "GetFullUserName", arrSqlParam);
|
| ------------------------
| CREATE PROCEDURE GetFullUserName
| @strUserName nvarchar(50),
| @strUserNameFull nvarchar(100) OUT
| AS
|
| SET @strUserNameFull = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
| [tblUsers].[user_name] = @strUserName)
| GO
|
|
|
Uf ... Thanx I'll try this, I thought that Execute.Scalar returns a single
value, and that Execute.NoQuery is used when executing INSERT, DELETE or
UPDATE.
Neven
"bruce barker" <no***********@safeco.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl... you sp has no result set, so execute scaler is returning an error. execute scalre returns the first column of the first result set. if there is no result set, then its stuck.
change you proc to return the name in a result set, or use ExecuteNoQuery, and get the value from the sp parameter (which must be declared an out in your code to work).
-- bruce (sqlwork.com)
"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message news:en**************@TK2MSFTNGP15.phx.gbl... | Hi, | | I have a problem with SqlHelper.ExecuteScalar ... | | When I try to execute SqlHelper.ExecuteScalar I get this message: | "System.InvalidCastException: Object must implement IConvertible.". | | Help ... | | Thanx, Neven | | ---------------------- | SqlParameter[] arrSqlParam = null; | arrSqlParam = | SqlHelperParameterCache.GetSpParameterSet(DB.getCo nnectiongString(), | "GetFullUserName"); | arrSqlParam[0].Value = strUserName; | | strFullUserName = Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(), | "GetFullUserName", arrSqlParam); | | ------------------------ | CREATE PROCEDURE GetFullUserName | @strUserName nvarchar(50), | @strUserNameFull nvarchar(100) OUT | AS | | SET @strUserNameFull = (SELECT ime + ' ' + prezime FROM tblUsers WHERE | [tblUsers].[user_name] = @strUserName) | GO | | |
I just remembered and checked ... ExecuteNonQuery returns int ?
Neven
"bruce barker" <no***********@safeco.com> wrote in message
news:uS**************@TK2MSFTNGP11.phx.gbl... you sp has no result set, so execute scaler is returning an error. execute scalre returns the first column of the first result set. if there is no result set, then its stuck.
change you proc to return the name in a result set, or use ExecuteNoQuery, and get the value from the sp parameter (which must be declared an out in your code to work).
-- bruce (sqlwork.com)
"Neven Klofutar" <neven.klofutar*r.e..mo*****@vip.hr> wrote in message news:en**************@TK2MSFTNGP15.phx.gbl... | Hi, | | I have a problem with SqlHelper.ExecuteScalar ... | | When I try to execute SqlHelper.ExecuteScalar I get this message: | "System.InvalidCastException: Object must implement IConvertible.". | | Help ... | | Thanx, Neven | | ---------------------- | SqlParameter[] arrSqlParam = null; | arrSqlParam = | SqlHelperParameterCache.GetSpParameterSet(DB.getCo nnectiongString(), | "GetFullUserName"); | arrSqlParam[0].Value = strUserName; | | strFullUserName = Utility.SqlHelper.ExecuteScalar(DB.getConnectiongS tring(), | "GetFullUserName", arrSqlParam); | | ------------------------ | CREATE PROCEDURE GetFullUserName | @strUserName nvarchar(50), | @strUserNameFull nvarchar(100) OUT | AS | | SET @strUserNameFull = (SELECT ime + ' ' + prezime FROM tblUsers WHERE | [tblUsers].[user_name] = @strUserName) | GO | | |
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rajesh Madhra |
last post by:
Hi everybody
I just solved my probem about creating my own assemblies by using the
command line
vbc /nologo /t:library /out:MyClass.dll ... MyClass.vb with your help. But I
still cannot make...
|
by: Brian |
last post by:
I am trying to pass a null value into a stored procedure
so that it can save the data. I am using Microsoft's
SQLHelper dll to do this. My example code is below. How
do I pass in a null value...
|
by: Rajesh Kumar |
last post by:
Hi Gregory
Thanks for your answer. I did not see any attached file so I copied your
text into a text file and named it compiler.bat
Checked the wrapped lines and runned the file. It said Dataset,...
|
by: Rajesh Madhra |
last post by:
Hi Gregory
Thanks for your answer. I did not see any attached file so I copied your
text into a text file and named it compiler.bat
Checked the wrapped lines and runned the file. It said Dataset,...
|
by: Chad Dittmer via .NET 247 |
last post by:
I'm having problems inserting into Sql 2000 using SqlHelper.ExecuteScalar.
When it inserts, it only takes the first character from the string?? Any help would be appreciated. Here is the code and...
| |
by: FyinsFlip |
last post by:
Microsoft Data Access Blocks (SqlHelper) you can do an insert and get
the new row ID without using a stored procedure?
DataMembers.Car_IDObject = SqlHelper.ExecuteScalar( _connectionString ,...
|
by: RJN |
last post by:
Hi
I want to get the rerurn value from a stored procedure
My stored proc looks like this
create proc test
.....
if..
return 1
|
by: John F |
last post by:
Hello All,
What is the consensus on using sqlhelper or not using sqlhelper when calling
stored procedures?
We're trying to go with a standard for our projects and personally I prefer
not...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |