Unidentifier in Guidview update with error

W

Wu

Dear All Readers,

Can somebody give me some hints or advices?

I have a table in SQL 2005 express as below:

Fieldname DataType
RecID Uniqueidentifier
Info_Type nvarchar(200)
RecStatus bit
RecStatusDT datetime

I have used the dataset named info_type.xsd with the info_typeTableAdapter.
This TableAdapter has three functios such as

1) Fill,GetData() > All data in this table
2) FillByRecID, GetDataByRecID (@recid) > Get all columns by RecID
3) InfoType_update(@recid, @info_type) > Update the Info_Type field by
RecID

#2 and #3 have the stored procedure
------------------------------------
#2 Stored procedure as below:
------------------------------------
ALTER PROCEDURE InfoType_selectByInfo_Type

(
@recid char(36)
)
AS

declare @guid char(36)
set @guid = cast(@recid as char(36))

select *
from Info_Type
where RecID = @guid


return
-------------------------------------
#3 Stored Procedure as below:
-------------------------------------

LTER PROCEDURE InfoType_update
(
@recid char(36),
@info_type nvarchar(200)
)

AS
declare @guid char(36)
set @guid = cast(@recid as char(36))

update Info_Type
set Info_Type = @info_type,
RecStatusDT = getdate()
where RecID = @guid

return

---------------------------------------------

I have a gridview in default.aspx and with edition function and show all the
above fields with DataKeyNames = RecID. However, when I clicked update,
then it shows the following error:

Server Error in '/WebSite2' Application.
--------------------------------------------------------------------------------

Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement
IConvertible.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:


[InvalidCastException: Object must implement IConvertible.]
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +2880621
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +141
System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean
ignoreNullableTypeChanges) +63
System.Web.UI.WebControls.ObjectDataSourceView.MergeDictionaries(ParameterCollection
reference, IDictionary source, IDictionary destination, String
parameterNameFormatString) +423
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +907
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values,
IDictionary oldValues, DataSourceViewOperationCallback callback) +92
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32
rowIndex, Boolean causesValidation) +907
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +704
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs
e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source,
EventArgs e) +123
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +135
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

--------------------------------------------------------------------------------Version Information: Microsoft .NET Framework Version:2.0.50727.3053;ASP.NET Version:2.0.50727.3053Please advice me because I am a starter in Programming. Thanks.Wu
 
W

Wu

Dear Readers,

Additionally,

I also have a BLL (Business Logic Layer) with the code below:


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using InfoTypeTableAdapters;


/// <summary>
/// Summary description for Class1
/// </summary>

[System.ComponentModel.DataObject]

public class Class1
{
private Info_TypeTableAdapter _infotypeAdapter = null;

protected Info_TypeTableAdapter Adapter
{
get
{
if (_infotypeAdapter == null)
_infotypeAdapter = new Info_TypeTableAdapter();

return _infotypeAdapter;
}

}

[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select, true)]
public InfoType.Info_TypeDataTable GetInfoType()
{
return Adapter.GetData();
}


[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select, false)]
public InfoType.Info_TypeDataTable GetRecIDByRecID(string recid)
{
return Adapter.GetDataByRecID(recid);



Wu said:
Dear All Readers,

Can somebody give me some hints or advices?

I have a table in SQL 2005 express as below:

Fieldname DataType
RecID Uniqueidentifier
Info_Type nvarchar(200)
RecStatus bit
RecStatusDT datetime

I have used the dataset named info_type.xsd with the
info_typeTableAdapter. This TableAdapter has three functios such as

1) Fill,GetData() > All data in this table
2) FillByRecID, GetDataByRecID (@recid) > Get all columns by RecID
3) InfoType_update(@recid, @info_type) > Update the Info_Type field by
RecID

#2 and #3 have the stored procedure
------------------------------------
#2 Stored procedure as below:
------------------------------------
ALTER PROCEDURE InfoType_selectByInfo_Type

(
@recid char(36)
)
AS

declare @guid char(36)
set @guid = cast(@recid as char(36))

select *
from Info_Type
where RecID = @guid


return
-------------------------------------
#3 Stored Procedure as below:
-------------------------------------

LTER PROCEDURE InfoType_update
(
@recid char(36),
@info_type nvarchar(200)
)

AS
declare @guid char(36)
set @guid = cast(@recid as char(36))

update Info_Type
set Info_Type = @info_type,
RecStatusDT = getdate()
where RecID = @guid

return

---------------------------------------------

I have a gridview in default.aspx and with edition function and show all
the above fields with DataKeyNames = RecID. However, when I clicked
update, then it shows the following error:

Server Error in '/WebSite2' Application.
--------------------------------------------------------------------------------

Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement
IConvertible.

Source Error:

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidCastException: Object must implement IConvertible.]
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +2880621
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +141
System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean
ignoreNullableTypeChanges) +63

System.Web.UI.WebControls.ObjectDataSourceView.MergeDictionaries(ParameterCollection
reference, IDictionary source, IDictionary destination, String
parameterNameFormatString) +423
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +907
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback callback)
+92
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32
rowIndex, Boolean causesValidation) +907
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +704
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
+37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source,
EventArgs e) +123
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
+37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +135

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

--------------------------------------------------------------------------------Version
Information: Microsoft .NET Framework Version:2.0.50727.3053;ASP.NET
Version:2.0.50727.3053Please advice me because I am a starter in
Programming. Thanks.Wu
 
W

Wu

}
[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Update, true)]

public bool UpdateInfoType(string Info_Type, string RecID)
{
InfoType.Info_TypeDataTable infotypes =
Adapter.GetDataByRecID(RecID);
if (infotypes.Count == 0)
// no matching record found, return false
return false;
else
{
System.Guid gg = new System.Guid(RecID.ToString());
InfoType.Info_TypeRow infotype = infotypes[0];
infotype.RecID = gg;
infotype.Info_Type = Info_Type;

// Update the product record
int rowAffected = Adapter.Update(infotype);

// Return true if precisely one row was updated,
// otherwise false
return rowAffected == 1;

//_infotypeAdapter.Update(Info_Type, RecStatus, RecStatusDT,
gg);

}
}


Wu said:
Dear Readers,

Additionally,

I also have a BLL (Business Logic Layer) with the code below:


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using InfoTypeTableAdapters;


/// <summary>
/// Summary description for Class1
/// </summary>

[System.ComponentModel.DataObject]

public class Class1
{
private Info_TypeTableAdapter _infotypeAdapter = null;

protected Info_TypeTableAdapter Adapter
{
get
{
if (_infotypeAdapter == null)
_infotypeAdapter = new Info_TypeTableAdapter();

return _infotypeAdapter;
}

}

[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select, true)]
public InfoType.Info_TypeDataTable GetInfoType()
{
return Adapter.GetData();
}


[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select, false)]
public InfoType.Info_TypeDataTable GetRecIDByRecID(string recid)
{
return Adapter.GetDataByRecID(recid);



Wu said:
Dear All Readers,

Can somebody give me some hints or advices?

I have a table in SQL 2005 express as below:

Fieldname DataType
RecID Uniqueidentifier
Info_Type nvarchar(200)
RecStatus bit
RecStatusDT datetime

I have used the dataset named info_type.xsd with the
info_typeTableAdapter. This TableAdapter has three functios such as

1) Fill,GetData() > All data in this table
2) FillByRecID, GetDataByRecID (@recid) > Get all columns by RecID
3) InfoType_update(@recid, @info_type) > Update the Info_Type field by
RecID

#2 and #3 have the stored procedure
------------------------------------
#2 Stored procedure as below:
------------------------------------
ALTER PROCEDURE InfoType_selectByInfo_Type

(
@recid char(36)
)
AS

declare @guid char(36)
set @guid = cast(@recid as char(36))

select *
from Info_Type
where RecID = @guid


return
-------------------------------------
#3 Stored Procedure as below:
-------------------------------------

LTER PROCEDURE InfoType_update
(
@recid char(36),
@info_type nvarchar(200)
)

AS
declare @guid char(36)
set @guid = cast(@recid as char(36))

update Info_Type
set Info_Type = @info_type,
RecStatusDT = getdate()
where RecID = @guid

return

---------------------------------------------

I have a gridview in default.aspx and with edition function and show all
the above fields with DataKeyNames = RecID. However, when I clicked
update, then it shows the following error:

Server Error in '/WebSite2' Application.
--------------------------------------------------------------------------------

Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement
IConvertible.

Source Error:

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidCastException: Object must implement IConvertible.]
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +2880621
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +141
System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean
ignoreNullableTypeChanges) +63

System.Web.UI.WebControls.ObjectDataSourceView.MergeDictionaries(ParameterCollection
reference, IDictionary source, IDictionary destination, String
parameterNameFormatString) +423

System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +907
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback callback)
+92
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32
rowIndex, Boolean causesValidation) +907
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +704
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
+37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source,
EventArgs e) +123
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
+37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +135

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+175
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1565

--------------------------------------------------------------------------------Version
Information: Microsoft .NET Framework Version:2.0.50727.3053;ASP.NET
Version:2.0.50727.3053Please advice me because I am a starter in
Programming. Thanks.Wu
 
W

Wu

Hello,

Please refer to this link http://forums.asp.net/t/1363272.aspx
for solution.

Wu

Wu said:
Dear All Readers,

Can somebody give me some hints or advices?

I have a table in SQL 2005 express as below:

Fieldname DataType
RecID Uniqueidentifier
Info_Type nvarchar(200)
RecStatus bit
RecStatusDT datetime

I have used the dataset named info_type.xsd with the
info_typeTableAdapter. This TableAdapter has three functios such as

1) Fill,GetData() > All data in this table
2) FillByRecID, GetDataByRecID (@recid) > Get all columns by RecID
3) InfoType_update(@recid, @info_type) > Update the Info_Type field by
RecID

#2 and #3 have the stored procedure
------------------------------------
#2 Stored procedure as below:
------------------------------------
ALTER PROCEDURE InfoType_selectByInfo_Type

(
@recid char(36)
)
AS

declare @guid char(36)
set @guid = cast(@recid as char(36))

select *
from Info_Type
where RecID = @guid


return
-------------------------------------
#3 Stored Procedure as below:
-------------------------------------

LTER PROCEDURE InfoType_update
(
@recid char(36),
@info_type nvarchar(200)
)

AS
declare @guid char(36)
set @guid = cast(@recid as char(36))

update Info_Type
set Info_Type = @info_type,
RecStatusDT = getdate()
where RecID = @guid

return

---------------------------------------------

I have a gridview in default.aspx and with edition function and show all
the above fields with DataKeyNames = RecID. However, when I clicked
update, then it shows the following error:

Server Error in '/WebSite2' Application.
--------------------------------------------------------------------------------

Object must implement IConvertible.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Object must implement
IConvertible.

Source Error:

An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidCastException: Object must implement IConvertible.]
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +2880621
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +141
System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean
ignoreNullableTypeChanges) +63

System.Web.UI.WebControls.ObjectDataSourceView.MergeDictionaries(ParameterCollection
reference, IDictionary source, IDictionary destination, String
parameterNameFormatString) +423
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +907
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback callback)
+92
System.Web.UI.WebControls.GridView.HandleUpdate(GridViewRow row, Int32
rowIndex, Boolean causesValidation) +907
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean
causesValidation, String validationGroup) +704
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source,
EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
+37
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source,
EventArgs e) +123
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
+37
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) +135

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

--------------------------------------------------------------------------------Version
Information: Microsoft .NET Framework Version:2.0.50727.3053;ASP.NET
Version:2.0.50727.3053Please advice me because I am a starter in
Programming. Thanks.Wu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top