473,624 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SqlHelper.Execu teScalar

Hi,

I have a problem with SqlHelper.Execu teScalar ...

When I try to execute SqlHelper.Execu teScalar I get this message:
"System.Invalid CastException: Object must implement IConvertible.".

Help ...

Thanx, Neven

----------------------
SqlParameter[] arrSqlParam = null;
arrSqlParam =
SqlHelperParame terCache.GetSpP arameterSet(DB. getConnectiongS tring(),
"GetFullUserNam e");
arrSqlParam[0].Value = strUserName;

strFullUserName = Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(),
"GetFullUserNam e", arrSqlParam);

------------------------
CREATE PROCEDURE GetFullUserName
@strUserName nvarchar(50),
@strUserNameFul l nvarchar(100) OUT
AS

SET @strUserNameFul l = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
[tblUsers].[user_name] = @strUserName)
GO

Nov 19 '05 #1
7 12006
ExecuteScalar returns a Object type..you should cast this object to a string
like so:

strFullUserName = (string)
Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(),
"GetFullUserNam e", arrSqlParam);

"Neven Klofutar" wrote:
Hi,

I have a problem with SqlHelper.Execu teScalar ...

When I try to execute SqlHelper.Execu teScalar I get this message:
"System.Invalid CastException: Object must implement IConvertible.".

Help ...

Thanx, Neven

----------------------
SqlParameter[] arrSqlParam = null;
arrSqlParam =
SqlHelperParame terCache.GetSpP arameterSet(DB. getConnectiongS tring(),
"GetFullUserNam e");
arrSqlParam[0].Value = strUserName;

strFullUserName = Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(),
"GetFullUserNam e", arrSqlParam);

------------------------
CREATE PROCEDURE GetFullUserName
@strUserName nvarchar(50),
@strUserNameFul l nvarchar(100) OUT
AS

SET @strUserNameFul l = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
[tblUsers].[user_name] = @strUserName)
GO

Nov 19 '05 #2
It's not that, I still get an error, I also tried this:

strFullUserName =
Convert.ToStrin g(Utility.SqlHe lper.ExecuteSca lar(Utility.DB. getConnectiongS t
ring(), "GetFullUserNam e", arrSqlParam));
"Tampa .NET Koder" <Ta***********@ discussions.mic rosoft.com> wrote in
message news:C3******** *************** ***********@mic rosoft.com...
ExecuteScalar returns a Object type..you should cast this object to a string like so:

strFullUserName = (string)
Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(),
"GetFullUserNam e", arrSqlParam);

"Neven Klofutar" wrote:
Hi,

I have a problem with SqlHelper.Execu teScalar ...

When I try to execute SqlHelper.Execu teScalar I get this message:
"System.Invalid CastException: Object must implement IConvertible.".

Help ...

Thanx, Neven

----------------------
SqlParameter[] arrSqlParam = null;
arrSqlParam =
SqlHelperParame terCache.GetSpP arameterSet(DB. getConnectiongS tring(),
"GetFullUserNam e");
arrSqlParam[0].Value = strUserName;

strFullUserName = Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(), "GetFullUserNam e", arrSqlParam);

------------------------
CREATE PROCEDURE GetFullUserName
@strUserName nvarchar(50),
@strUserNameFul l nvarchar(100) OUT
AS

SET @strUserNameFul l = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
[tblUsers].[user_name] = @strUserName)
GO

Nov 19 '05 #3
Utility.SqlHelp er ... is not an error, I put it in my library ...

Neven

strFullUserName =
Convert.ToStrin g(Utility.SqlHe lper.ExecuteSca lar(Utility.DB. getConnectiongS t ring(), "GetFullUserNam e", arrSqlParam));
"Tampa .NET Koder" <Ta***********@ discussions.mic rosoft.com> wrote in
message news:C3******** *************** ***********@mic rosoft.com...
ExecuteScalar returns a Object type..you should cast this object to a

string
like so:

strFullUserName = (string)
Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(),
"GetFullUserNam e", arrSqlParam);

"Neven Klofutar" wrote:
Hi,

I have a problem with SqlHelper.Execu teScalar ...

When I try to execute SqlHelper.Execu teScalar I get this message:
"System.Invalid CastException: Object must implement IConvertible.".

Help ...

Thanx, Neven

----------------------
SqlParameter[] arrSqlParam = null;
arrSqlParam =
SqlHelperParame terCache.GetSpP arameterSet(DB. getConnectiongS tring(),
"GetFullUserNam e");
arrSqlParam[0].Value = strUserName;

strFullUserName = Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(), "GetFullUserNam e", arrSqlParam);

------------------------
CREATE PROCEDURE GetFullUserName
@strUserName nvarchar(50),
@strUserNameFul l nvarchar(100) OUT
AS

SET @strUserNameFul l = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
[tblUsers].[user_name] = @strUserName)
GO


Nov 19 '05 #4

"Neven Klofutar" <neven.klofutar *r.e..mo*****@v ip.hr> wrote in message
news:en******** ******@TK2MSFTN GP15.phx.gbl...
Hi,

I have a problem with SqlHelper.Execu teScalar ...


Confusingly, ExecuteScalar is for commands which return result sets.
You want ExecuteNonQuery , and then examine the parameter.
David
Nov 19 '05 #5
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*****@v ip.hr> wrote in message
news:en******** ******@TK2MSFTN GP15.phx.gbl...
| Hi,
|
| I have a problem with SqlHelper.Execu teScalar ...
|
| When I try to execute SqlHelper.Execu teScalar I get this message:
| "System.Invalid CastException: Object must implement IConvertible.".
|
| Help ...
|
| Thanx, Neven
|
| ----------------------
| SqlParameter[] arrSqlParam = null;
| arrSqlParam =
| SqlHelperParame terCache.GetSpP arameterSet(DB. getConnectiongS tring(),
| "GetFullUserNam e");
| arrSqlParam[0].Value = strUserName;
|
| strFullUserName =
Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(),
| "GetFullUserNam e", arrSqlParam);
|
| ------------------------
| CREATE PROCEDURE GetFullUserName
| @strUserName nvarchar(50),
| @strUserNameFul l nvarchar(100) OUT
| AS
|
| SET @strUserNameFul l = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
| [tblUsers].[user_name] = @strUserName)
| GO
|
|
|
Nov 19 '05 #6
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******** ******@TK2MSFTN GP11.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*****@v ip.hr> wrote in message
news:en******** ******@TK2MSFTN GP15.phx.gbl...
| Hi,
|
| I have a problem with SqlHelper.Execu teScalar ...
|
| When I try to execute SqlHelper.Execu teScalar I get this message:
| "System.Invalid CastException: Object must implement IConvertible.".
|
| Help ...
|
| Thanx, Neven
|
| ----------------------
| SqlParameter[] arrSqlParam = null;
| arrSqlParam =
| SqlHelperParame terCache.GetSpP arameterSet(DB. getConnectiongS tring(),
| "GetFullUserNam e");
| arrSqlParam[0].Value = strUserName;
|
| strFullUserName =
Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(),
| "GetFullUserNam e", arrSqlParam);
|
| ------------------------
| CREATE PROCEDURE GetFullUserName
| @strUserName nvarchar(50),
| @strUserNameFul l nvarchar(100) OUT
| AS
|
| SET @strUserNameFul l = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
| [tblUsers].[user_name] = @strUserName)
| GO
|
|
|

Nov 19 '05 #7
I just remembered and checked ... ExecuteNonQuery returns int ?

Neven
"bruce barker" <no***********@ safeco.com> wrote in message
news:uS******** ******@TK2MSFTN GP11.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*****@v ip.hr> wrote in message
news:en******** ******@TK2MSFTN GP15.phx.gbl...
| Hi,
|
| I have a problem with SqlHelper.Execu teScalar ...
|
| When I try to execute SqlHelper.Execu teScalar I get this message:
| "System.Invalid CastException: Object must implement IConvertible.".
|
| Help ...
|
| Thanx, Neven
|
| ----------------------
| SqlParameter[] arrSqlParam = null;
| arrSqlParam =
| SqlHelperParame terCache.GetSpP arameterSet(DB. getConnectiongS tring(),
| "GetFullUserNam e");
| arrSqlParam[0].Value = strUserName;
|
| strFullUserName =
Utility.SqlHelp er.ExecuteScala r(DB.getConnect iongString(),
| "GetFullUserNam e", arrSqlParam);
|
| ------------------------
| CREATE PROCEDURE GetFullUserName
| @strUserName nvarchar(50),
| @strUserNameFul l nvarchar(100) OUT
| AS
|
| SET @strUserNameFul l = (SELECT ime + ' ' + prezime FROM tblUsers WHERE
| [tblUsers].[user_name] = @strUserName)
| GO
|
|
|

Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2979
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 assembly for SQLHelper class. After installing Appl. Block Data Access I got a file SQLHelper.vb. When I tried to use the same command vbc /nologo ....... SQLHelper.vb, i got some errors. Can someone tell me in detail what is the process to get Appl....
3
8396
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 as a parameter? For example, in the code below, miVendorID is declared as an Object. The save attempt fails if the object has not been populated (for example, the person choose not to select a vendor from the dropdown list) I have the same...
0
1638
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, Datareader and some other things are not defined. So I entered the : Imports Microsoft.ApplicationBlocks.Data Imports system Imports system.data Imports System.Data.SqlClient
0
3360
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, Datareader and some other things are not defined. So I entered the : Imports Microsoft.ApplicationBlocks.Data Imports system Imports system.data Imports System.Data.SqlClient
1
3051
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 the stored procedure I'm using. Dim newRowId As Integer newRowId = Convert.ToInt32(SqlHelper.ExecuteScalar(ConfigurationSettings.AppSettings("ConnectionString"), "ProcContactsInsert", 1234, "hparameter2", "parameter2", "tparamer2", "pareter2",...
4
2867
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 , "INSERT INTO tCar (name) VALUES ('Ford') SELECT CAST(@@Identity AS INTEGER) ", FillSqlParameter()); Is there a new line symbol I can add before the SELECT, like a ';' or something?
7
7533
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
4
2119
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 using sqlhelper, but some here do. I'm just curious if there are any good arguments for or against it... Thanks,
0
8246
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8631
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8490
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1489
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.