473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Enterprise Library.DATA - Nov/Dec Preview - Failed to convert parameter value from a SqlParameter to a String.

I am having major problems using GetStoredProcCommand and using Parameters
in the same function call in the latest builds of the Enterprise Library
Data.

The error I get is :

Failed to convert parameter value from a SqlParameter to a String.

Here is some code that works and does not work.

// This Works
DbCommand dbCommand1 = new SqlCommand();
dbCommand1.Connection = new
SqlConnection("Server=MyServer;Database=MyDB;uid=M yUID;pwd=MyPassword;");
dbCommand1.CommandType = CommandType.StoredProcedure;
dbCommand1.CommandText = "HTMLGetPageIDFromName";
dbCommand1.Parameters.Add(new SqlParameter("@PageName", PageName));
dbCommand1.Connection.Open();
object value1 = dbCommand1.ExecuteScalar();

// Shared

Database db = DatabaseFactory.CreateDatabase();

// This works
DbCommand dbCommand2 =
db.GetStoredProcCommand("HTMLGetPageIDFromName");
db.AddInParameter(dbCommand2, "@PageName", DbType.String, PageName);
object value2 = db.ExecuteScalar(dbCommand2);

// This does not work
DbCommand dbCommand3 =
db.GetStoredProcCommand("HTMLGetPageIDFromName",
new SqlParameter("@PageName", PageName));
object value3 = db.ExecuteScalar(dbCommand3);

The code that does not work causes an Exception on the
db.ExecuteScaler(dbCommand3)

Failed to convert parameter value from a SqlParameter to a String.

Looking at the details I see there is an inner exception

{"Object must implement IConvertible."}

I have spent hours on this and I can not find anything specifc that is
causing the issue. It fails in both the November and December releases.

The exception comes from within the DBCommand.ExecuteScaler method call.

The example that fails loads the parameter types from the database and I
think this is causing the issue but I can not fix it.

Is this a known problem?

Cheers

Chris Crowe [IIS MVP 1997 -> 2006]
http://blog.crowe.co.nz
------------------------------------------------

Dec 5 '05 #1
0 1675

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

Similar topics

1
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland...
0
by: Alex | last post by:
Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Configuration Public Class Main : Inherits Page ...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
5
by: Mark | last post by:
I have a VB 6 program that I have saved an audio file to using DAO and the appendchunk as is shown at http://support.microsoft.com/kb/103257/EN-US/. ; I have it working fine in that app (it saves...
0
by: TattedProgrammer | last post by:
Hello All, I am completely stuck, I have tried for an entire day to get a simple procedure call to my Oracle Db via the enterprise Library 06. I am not an oracle fan to start, but have to deal...
5
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the...
0
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE TO...
5
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE...
4
by: sweatha | last post by:
Hi In sql server 2005 I have a column as GraduationYear Decimal(4,0). In asp.net I used the coding for that as SqlParameter GraduationYear = new SqlParameter("@GraduationYear",...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.