DataSource Controls :: Failed To Convert Parameter Value From A String To A Guid?

Jun 3, 2010

I am trying to get the 'userid' of the logged in user using the code below:

"MembershipUser myObject = Membership.GetUser();
String userId = myObject.ProviderUserKey.ToString();"

and later using it as a parameter to the stored procedure.

The logic here is, the user should login first in order to retrieve his/her album. when the user is logged in, im retrieving the 'userid' and using it as parameter to load the corresponding album from the database.

when i login and open the albumpage, im end up with this exception:

"Failed to convert parameter value from a String to a Guid".

What could be the reason and how can i avoid this exception.

by the way im using the aspnet_Users table's userid field.

View 7 Replies


Similar Messages:

Exception:Failed To Convert Parameter Value From A Guid To A String?

Jan 22, 2010

I have a problem while creating a web application using LinqTemplate here is the explanation step wise....
1.I have created a database with a table name UserTest with one column name UserId with uniqidentifier datatype2. I have created a classLiberary Project where i have used LinqTemplate of subsonic for code Generation of DAL and created a partial class for UserTest

public partial class TestUser:Classes
{
public int Insert(TestUser user)

[code]...

Now when I Build the project it build successfully and when i run the project it shows
the UserTest.aspx page with a button but when i click on button it must insert the new guid value into the table butit throws an exception

[InvalidCastException: Object must implement IConvertible.]
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +2560525
System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) +414
[InvalidCastException: Failed to convert parameter value from a Guid to a String.]
TestPages.UserEdit.btnCreateNewAccount_Click(Object sender, EventArgs e) in D:TestPagesUserEdit.aspx.cs:61
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105

View 1 Replies

SQL Server :: Failed To Convert Parameter Value From A String To A Guid?

Aug 22, 2010

I am trying to get the UserRole from the logged in user and send it to the database table my code is:

[Code]....

View 1 Replies

DataSource Controls :: Failed To Convert Parameter Value From String To Int32?

Jan 10, 2011

I swear I'm overthinking this as I've tried different combinations to do an insert from Code Behind to my Sql DB.

This is what my table looks like:

[Code]....

My code behind:

[Code]....

I suspect that the problem may be my date. The format that goes from the UI is mm/dd/yyyy.

View 2 Replies

Forms Data Controls :: Failed To Convert Parameter Value From A DataControlFieldCell To A String - GridView Error

Nov 18, 2010

[Code]....

Forms Data Controls :: Failed to convert parameter value from a DataControlFieldCell to a String - GridView Error?

View 6 Replies

Failed To Convert Parameter Value From A String To A Int32?

Jan 12, 2010

I'm using a GridView control to edit data in a MySQL database.

I've created the C# code behind but I'm having trouble pulling back the parameter from a radiobutton control to populate an Int32 field in the database. I'm getting "Input string not in correct format"This is the particular bit (amongst a host of others of the same type) that is causing the problem:

cmd.Parameters.Add("?yes", OdbcType.Int).Value = (Convert.ToInt32(((RadioButton)GridView2.Rows[i].FindControl("edYes")).Text));

View 3 Replies

Failed To Convert Parameter Value From A String To A DateTime?

Dec 17, 2010

I have written a code to insert emp details into database and i am also inserting local date(i,e system date) into to the table to know/have an idea at what date the employee inserted details. I have set date format add/MM/yyyy and its working well in my local system, but after uploading the site into server (the server is shared server) iam getting error and the error message is Failed to convert parameter value from a String to a DateTime.

Surprisingly, it is working well in server when i chaged the date format to MM/dd/yyyy, but now its not working in my local system and getting the same error.

View 2 Replies

Failed To Convert Parameter Type To String

Mar 20, 2011

here is my code......where its throwing the error in storeimage.executenonquery() line that Failed to convert parameter type to st

if (newBmp != null)
{
Bitmap convBmp = AddTextToImage(newBmp, text);
Byte[] myimage=ImageToByteArray(convBmp);
//string type = myimage.GetType();
// String query = ;

[Code]....

View 4 Replies

Failed To Convert Parameter Value From String To Int32

Aug 30, 2010

I am not sure where my app is failing but most probably this is where it is failing.. I think lblExpID.Text is the culprit. Here's the relvant part of my code:

Dim lblExpID As Label
For Each item In LSGrid.Rows
lblExpID = item.FindControl("lblID")
If txtExpGenFund.Text <> "" Then
sqlArray(i) = ExpDetailsID & "," & (lblExpID.Text) & "," & MunID & "," & _
Val(txtExpGenFund.Text) & "," & Val(txtExpDetSpecialRevenue.Text) & "," & _
Val(txtExpDetCapitalProjects.Text) & "," & expTotal & "," & reportingYear & "," & "Test Comments" & "," & UserID
End If

Can u help me identify why i am getting this error looking at the sp below:

PROCEDURE [dbo].[uspEXPENDITURE_DETAILS]
(
@ExpDetailsID int=0 output,
@ExpDet_ExpID int,
@ExpDet_Municipality_ID nvarchar(50),
@ExpDetGeneralFund money,
@ExpDetSpecialRevenue money,
@ExpDetCapitalProjects money,
@ExpDetTotal money,
@Exp_Reporting_Year varchar(10),
@ExpComments varchar(max),
@Contact_ID int
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

delete from [dbo].[TBL_EXPENDITURE_DETAILS] where ExpDet_ExpID=@ExpDet_ExpID and ExpDet_Municipality_ID=@ExpDet_Municipality_ID and Exp_Reporting_Year=@Exp_Reporting_Year

If @ExpDetailsID >= 0
Begin
INSERT INTO [dbo].[TBL_EXPENDITURE_DETAILS]
([ExpDet_ExpID]
,[ExpDet_Municipality_ID]
,[ExpDetGeneralFund]
,[ExpDetSpecialRevenue]
,[ExpDetCapitalProjects]
,[ExpDetTotal]
,[Exp_Reporting_Year]
,[ExpComments]
,[ExpDetCreatedBy]
,[ExpDetCreateDate])
VALUES
(@ExpDet_ExpID,
@ExpDet_Municipality_ID,
@ExpDetGeneralFund,
@ExpDetSpecialRevenue,
@ExpDetCapitalProjects,
@ExpDetTotal,
@Exp_Reporting_Year,
@ExpComments,
@Contact_ID,
GetDate()
)
SET @ExpDetailsID = SCOPE_IDENTITY()
return @ExpDetailsID
end

View 12 Replies

C# - Failed To Convert Parameter Value From A String To A Boolean

Jun 28, 2010

I am getting an error msg when attempting to update a record from asp.net into a SQL database. The only boolean value being updated is:

cmdAddUser.Parameters.Add(new SqlParameter("@Active", SqlDbType.Bit));
cmdAddUser.Parameters["@Active"].Value =
Convert.ToBoolean(cbAddUserActiveUser.Checked);

The datatype for @Active in the database is "bit".

View 1 Replies

Web Forms :: Failed To Convert Parameter Value String To Decimal?

Mar 9, 2010

When running our web application the following message appears:

Failed to convert parameter value string to decimal. We believe that the problem might be with the sequence which generates the user_id. The user_id should be the output after successful insert of record. The stored procedure works well from within the DB and Visual Studio. Our DB version: 11gR1 on Windows.The web form has a button event with this c#-code:

[Code]....

[Code]....

View 7 Replies

Failed To Convert Parameter Value From A SqlParameter To A String - How To Fix This Error

Apr 12, 2010

I am using VS2008 with asp.net 3.5 and enterprise library 4.1. I am getting the following error when I try to connect to database.

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

Here is my code

[code]....

View 3 Replies

ADO.NET :: Getting Error As Failed To Convert Parameter Value From A String To Date Time

Nov 25, 2010

data.MakeInParam(
"@DOB",SqlDbType.DateTime,10,cust.DateOfBirth),

im new to .net, reponse grt intput for me to get in to it.

View 2 Replies

Forms Data Controls :: Convert String To GUID?

Mar 6, 2011

I know there are about a million posts on this topic, and I have attempeted to use many of them. However, I keep getting an error when I attempt a simple SQL update. Here is my code:

[Code]....

Here is my error:

[Code]....

View 3 Replies

Failed To Convert Parameter Message?

Oct 16, 2010

I'm trying to pass values in a SessionState from one page to another and then post them to a SQL database. When I click on the submit button on my submit page, I get this error:

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

Here is my submit page:

[code]....

View 4 Replies

SQL Server :: Failed To Convert Parameter Message?

Oct 16, 2010

I'm trying to pass values in a SessionState from one page to another and then post them to a SQL database. When I click on the submit button on my submit page, I get this error:

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

Here is my submit page:

[Code]....

I've verified that all of the input matches what I'm looking for on the SQL side.

View 31 Replies

DataSource Controls :: SqlBulkCopy - Invalid Cast From 'System.String' To 'System.Guid'

Feb 19, 2010

I am attempting to use SqlBulkCopy to import data from an XML document. I receive the following error when executing WriteToServer: Invalid cast from 'System.String' to 'System.Guid'

View 1 Replies

DataSource Controls :: Variable Connection String Parameter In A DataSource Control

May 20, 2010

I have several web forms which use a GridView linked to a DataSource control which is defined at design time as follows:

<cc1:pgsqldatasource
id="dsStates"
runat="server"
connectionstring="<%&#36; ConnectionStrings:PgSqlConnection %>"
oldvaluesparameterformatstring="Original_{0}"
providername="<%&#36; ConnectionStrings:PgSqlConnection.ProviderName %>" >
</cc1:pgsqldatasource>

As you can see, the connectionstring parameter is defined to a specific connection string name and I need to be able to set such a parameter to a different value, for example, to a session variable content.

View 1 Replies

DataSource Controls :: Conversion Failed When Converting Datetime From Character String?

Jan 13, 2010

Using the following quires, for select and Update,. Select qry is working fine ,but update qry throws 'conversion failed when converting datetime from character string' .

select * from table1 where CreatedDt >= convert(datetime,'12/23/2009',101) and createdDt < dateadd(d,1,convert(datetime,'12/23/2009',101))

Update Table1 set status = 'y' where CreatedDt>= convert(datetime,'12/23/2009',101) and CreatedDt < dateadd(d,1,convert(datetime,'12/23/2009',101)

View 2 Replies

DataSource Controls :: Conversion Failed From Converting Datetime To Character String

Feb 16, 2010

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[SP_ORDER_LIST]
@EmailId nvarchar(50)
AS
begin
declare @Id int
set @Id = (select SellerId from cart_seller_master where EmailId = @EmailId )
select
CTD.OrderId,CTD.Product_code,
CPM.product_name,CTD.Quantity,CTD.Orderdate,
case when convert(datetime,isnull(CTD.DispatchedDate,null)) is null then 'Not Dispatched'
end DispatchedDate ,
case when convert(datetime,isnull(CTD.DeliveryDate,null)) is null then 'Not Dispatched'
end DeliveryDate
from cart_Product_master as CPM
left outer join cart_Transaction_details as CTD on ctd.product_code=cpm.product_code
where CPM.SellerId = 1
group by CTD.OrderId,CTD.Product_code,
CPM.product_name,CTD.Quantity,CTD.Orderdate,
CTD.DispatchedDate,CTD.DeliveryDate
end

View 3 Replies

DataSource Controls :: Convert Sql Datetime To String

Feb 16, 2010

Datecol is a datetime in a sql table.

q="select convert(char(8),datecol1,112) from tblone where datecol2 is null"

is what I use for my query string for sqlcommand(). I'm getting the error "a field or property datecol1 could not be found in the datasource". Without the convert, the query is ok.

View 2 Replies

DataSource Controls :: Convert Records Into One String?

Jun 10, 2010

Convert records into one string

View 3 Replies

DataSource Controls :: Convert String To Datetime?

May 19, 2010

.aspx

[Code]....

And then when I save....cs

[Code]....

And Stored Procedure is like this

[Code]....

the problem is when I use debugging mode, I mean using with visual studio, it's going fine. But when I call from IIS there has a error.. Unterminated string constant. I know where is the problem

[Code]....

View 10 Replies

DataSource Controls :: Convert String To SQL Data Type?

Feb 22, 2010

how would one go about converting a string to an SQL time data type? Lets say i wanted to convert @param1 to SQL time and @param2 to SQL date.

[Code]....

View 1 Replies

DataSource Controls :: How To Convert String (comma Separated) To Int

Mar 1, 2010

I'm having a asp.net listbox on the front end webform with multiple selection, after user selecting multiple items, i'm capturing the DataKeyValue of listbox(which is amenity_id of bigint) and looping all the selected items to a string with comma sepearated values. For example if user selects first 4 options, my output string will be like this (1,2,3,4) and i'm passing this as a string type to my data access layer and then to my below stored proc. I'm geting this error while inserting.. i know that my data type is of bigint and i'm trying to insert string type. i need to convert the string type to INT type and insert data. below are my stored procs:

[Code]....

This is where i'm splitting the comma seperated values and inserting them into table.

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved