system.string cannot be converted to system.guid

A

afsheen

hello ,

there is another problem now..... i have a database(sql server 2000) which
has a field with datatype unique identifier rowguidcol.
In my application which is .net iam getting data via a web service in xml
whose format is different to the ado.net dataset format
it is in the xml ado recordset format ....below is the xml


<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
- <s:Schema id="RowsetSchema">
- <s:ElementType name="row" content="eltOnly">
- <s:AttributeType name="BatchGUID" rs:number="1" rs:nullable="true"
rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="uuid" dt:maxLength="16" rs:fixedlength="true" />
</s:AttributeType>
- <s:AttributeType name="DoctorGUID" rs:number="2" rs:nullable="true"
rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="uuid" dt:maxLength="16" rs:fixedlength="true" />
</s:AttributeType>
- <s:AttributeType name="BatchType" rs:number="3" rs:nullable="true"
rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="3" />
</s:AttributeType>
- <s:AttributeType name="BatchStartDate" rs:number="4" rs:nullable="true"
rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="dateTime" rs:dbtype="variantdate" dt:maxLength="16"
rs:fixedlength="true" />
</s:AttributeType>
- <s:AttributeType name="BatchEndDate" rs:number="5" rs:nullable="true"
rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="dateTime" rs:dbtype="variantdate" dt:maxLength="16"
rs:fixedlength="true" />
</s:AttributeType>
- <s:AttributeType name="BatchCnt" rs:number="6" rs:nullable="true"
rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="int" dt:maxLength="4" rs:precision="10"
rs:fixedlength="true" />
</s:AttributeType>
- <s:AttributeType name="BatchCntConfirm" rs:number="7" rs:maydefer="true"
rs:writeunknown="true">
<s:datatype dt:type="boolean" dt:maxLength="2" rs:fixedlength="true" />
</s:AttributeType>
- <s:AttributeType name="MaxStampDateTime" rs:number="8" rs:nullable="true"
rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="dateTime" rs:dbtype="variantdate" dt:maxLength="16"
rs:fixedlength="true" />
</s:AttributeType>
<s:extends type="rs:rowbase" />
</s:ElementType>
</s:Schema>
- <rs:data>
<z:row BatchGUID="{913FED2C-D796-4DBB-BCB7-5FECB02CF59D}"
DoctorGUID="{BA492309-027B-413E-9597-DD9385E4C536}" BatchType="SAM"
BatchStartDate="2004-03-09T16:01:25" BatchEndDate="2004-03-18T11:32:36"
BatchCnt="1" BatchCntConfirm="False" MaxStampDateTime="2004-03-18T11:32:36"
/>
</rs:data>
</xml>



i have to update my database table at the server with this data ..... the
fields here above (client side) are all not the same as the server
side table .... Iam looping thorough the z:row and getting all the
attribuutes and their values ... iam assigning these values to a new data
row that
iam creating for inserting this row into the db table .... Now the issue is
when i assign the "guid" value to the data row its data type becomes
system.string and when doing an update with da.Update(ds) throws an invalid
case error of system.string cannot be converted to system.guid.
How can i update my table as the uderlying value is a guid in the table

thanks
afsheen
 
V

Val Mazur

Hi,

I had similar problem before. What you need to do before assigning value to
the field is to convert string value into guid explicitly. If I remember
correctly, you could do this using next kind of code

Dim loGuid as Guid

loGuid = New Guid("MyStringValueHere")

Now assign it to the column
 

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