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

Home Posts Topics Members FAQ

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

I am having major problems using GetStoredProcCo mmand 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.Conn ection = new
SqlConnection(" Server=MyServer ;Database=MyDB; uid=MyUID;pwd=M yPassword;");
dbCommand1.Comm andType = CommandType.Sto redProcedure;
dbCommand1.Comm andText = "HTMLGetPageIDF romName";
dbCommand1.Para meters.Add(new SqlParameter("@ PageName", PageName));
dbCommand1.Conn ection.Open();
object value1 = dbCommand1.Exec uteScalar();

// Shared

Database db = DatabaseFactory .CreateDatabase ();

// This works
DbCommand dbCommand2 =
db.GetStoredPro cCommand("HTMLG etPageIDFromNam e");
db.AddInParamet er(dbCommand2, "@PageName" , DbType.String, PageName);
object value2 = db.ExecuteScala r(dbCommand2);

// This does not work
DbCommand dbCommand3 =
db.GetStoredPro cCommand("HTMLG etPageIDFromNam e",
new SqlParameter("@ PageName", PageName));
object value3 = db.ExecuteScala r(dbCommand3);

The code that does not work causes an Exception on the
db.ExecuteScale r(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.Execu teScaler 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 1691

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

Similar topics

1
4350
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 Interbase database. To do this, I copied and renamed the source files for working with a SQL Server database (SqlCommandWrapper.cs/SqlDatabase.cs to InterbaseCommandWrapper.cs/InterbaseDatabase.cs). I then changed all
0
1762
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 Private strConn As String =
2
6541
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 *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update or Insert
5
16105
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 to an access database and I can save the data back to a file using getchunk and everything works correctly). The issue is that I am now trying to access the database in VB.NET 2003 through an OleDBDataAdapter (Jet 4.0 connection) and can't get it...
0
1398
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 with it for now. I am only trying to retrieve data into a dataset from the oracle procedure, nothing fancy! Here is my 100th version of code I have.
5
1971
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 data adaptor.fill or datareader to retrieve the data it takes over 24 seconds. public System.Data.SqlClient.SqlDataReader List1(int PageIndex, int PageSize, string ItemName, string UserIDs, DateTime DateStart, DateTime DateEnd, int status,...
0
1722
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 TABLE, like storing IMAGE into DB. I hav searched lots of articles on that but didn't get success.
5
2972
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 TABLE, like storing IMAGE into DB.
4
10254
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", SqlDbType.Decimal); GraduationYear.Value = GYTextBox.Text; but while running I got error as
0
8249
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
8633
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...
1
8348
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7176
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2613
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 we have to send another system
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.