Showing posts with label value. Show all posts
Showing posts with label value. Show all posts

Friday, March 30, 2012

Problems ith Connection string to SQL Express

My application is usningtraditional connection string:

<

addkey="DbConnection"value="driver={SQL Native Driver}; provider=SQLNCLI;server=localhost;trusted_connection=yes;database=ebay" />

It works fine with database attached to SQL Server, how do I make this working with SQL Express attachable file in data directory?

I have tried this, but it does not work:

Provider=SQLNCLI;Server=RAF001\SQLExpress;AttachDbFilename=..\TestSite\App_Data\ebay.mdf;Database=ebay;Trusted_Connection=Yes;

Monday, March 26, 2012

Problems getting Date

Hello there

I have a date value on a sql server database.
When viewing this value using Enterprise Manager Tools it shows the date as 2006-11-23 10:59:52

When i load this value into my webservice object to pass to my handheld device its shows the date as 2006-11-23T10:59:51.6130000-00:00

Im trying to retrieve a date value from my sql server ce 2.0 database.
When i use Query Analyser on the device and view the date it shows 2006-11-23 10:59:51.613000000

Now in my application when i use .ExecuteScalar or .ExecuteReader and reader.GetDate() to retrieve this value it returns 2006-11-23 10:59:51

I need to pass the date from the device to the webservice which will return any records greater than this date but since there is a minute difference in the dates it does not work right....

How can i sort this out?

My only idea is to convert the date being inserted on the device database to be of yyyy-mm-dd hh:mm:ss only

DateTime is not stored as yyyy-mm-dd or as MM-DD-YY or whatever other string representations of the date and time there are.

Here's what date time really is (http://msdn2.microsoft.com/en-us/library/ms172424.aspx):

Date and time data from January 1, 1753, to December 31, 9999, with an accuracy of one three-hundredth second, or 3.33 milliseconds. Values are rounded to increments of .000, .003, or .007 milliseconds.

Stored as two 4-byte integers. The first 4 bytes store the number of days before or after the base date, January 1, 1900. The base date is the system's reference date. Values for datetime earlier than January 1, 1753, are not permitted. The other 4 bytes store the time of day represented as the number of milliseconds after midnight. Seconds have a valid range of 0–59.

My point is: these dates of yours are the same, just printed and rounded differently. I’m assuming you mean a second difference, not minute - note EM rounds 1.6 second to 2 resulting in 10:59:52 while printing it on device results in 10:59.51 with .6 second been truncated.

sql

Problems displaying default value of first cascading parameters.

I have 5 cascading parameters. They all have default values. I would like the default value of each of these to be selected when the report opens.

It currently works correctly when I preview the report, however when I deploy the report to the server it does not. In the deployed report, the default value of the first parameter is not selected. However, when I select a value for this one, on postback the rest of these parameters get set to their default value. They're all configured the same. I'm confused as to why the first one doesn't default to its default value while the others do.

Got any ideas?

Here's how I have it configured:

Allow null value CHECKED

Allow blank value CHECKED

The rest are unchecked.

Available values: From query

Default Values: Non-queried with a value supplied that exists in the dataset.

This issue got resolved when I deleted all of my reports from the server and then redeployed them. Funny how that works...sql

Problems displaying default value of first cascading parameters.

I have 5 cascading parameters. They all have default values. I would like the default value of each of these to be selected when the report opens.

It currently works correctly when I preview the report, however when I deploy the report to the server it does not. In the deployed report, the default value of the first parameter is not selected. However, when I select a value for this one, on postback the rest of these parameters get set to their default value. They're all configured the same. I'm confused as to why the first one doesn't default to its default value while the others do.

Got any ideas?

Here's how I have it configured:

Allow null value CHECKED

Allow blank value CHECKED

The rest are unchecked.

Available values: From query

Default Values: Non-queried with a value supplied that exists in the dataset.

This issue got resolved when I deleted all of my reports from the server and then redeployed them. Funny how that works...

Monday, March 12, 2012

Probleme with plusiers value of a field

Hello to all:

I have this request:

SELECT code_statusfac FROM factures WHERE code_statusfac in (:FILTRE)


While :FILTRE that can equal to some value, example:

' DIS02 ', ' DIS03 ', ' DIS04 ', etc.


When I execute the request and I replace:FILTRE by DIS04 that works well, but when I want to allocate him some value at the same moment it costs not.


What is what you have ideas PLEASE.

Thank you in advance.

Simple answer is use dynmaic query...

But be cautious about sql injection & other security concerns (it needs SELECT permission the table object).

Code Snippet

Exec ('SELECT code_statusfac FROM factures WHERE code_statusfac in (' + @.ListOfValues + ')')

Problematic Stored Procedures using Views with Triggers

Hi,

I would like to use the view of the company data in the following stored procedures

without needing to pass a value into the CompanyID identity column. Is there a way to do this? The following code contains the view, the insert trigger on the view, and the desired stored procedures.

Also, this code is given me problem as well the error message says it cannot convert varchar to int. This code is located in the insert trigger.

INSERT INTO State(StateName)
VALUES(@.StateName)

Here is the code of the company view, notice the C.CompanyID it is used in the GetCompany stored procedure.

SELECT C.CompanyID, C.CompanyName, A.Street, A.City, S.StateName, A.ZipCode, A.Country, P.PhoneNumber


FROM Company AS C INNER JOIN
Address AS A ON C.AddressID = A.AddressID INNER JOIN
State AS S ON A.StateID = S.StateID INNER JOIN
Phone AS P ON C.PhoneID = P.PhoneID

Here is code for the insert trigger on the view

CREATE TRIGGER InsertTriggerOnCustomerView
ON ViewOfCompany
INSTEAD OF INSERT
AS
BEGIN

DECLARE @.CompanyName VARCHAR(128)
DECLARE @.AddressID INT
DECLARE @.Street VARCHAR(256)
DECLARE @.City VARCHAR(128)
DECLARE @.StateID INT
DECLARE @.StateName VARCHAR(128)
DECLARE @.ZipCode INT
DECLARE @.Country VARCHAR(128)
DECLARE @.PhoneID INT
DECLARE @.PhoneNumber VARCHAR(32)
--DECLARE @.CompanyID INT

SELECT
--@.CompanyID = CompanyID,
@.CompanyName = CompanyName,
@.Street = Street,
@.City = City,
@.StateName = StateName,
@.ZipCode = ZipCode,
@.Country = Country,
@.PhoneNumber = PhoneNumber
FROM INSERTED

INSERT INTO State(StateName)
VALUES(@.StateName)

SET @.StateID = @.@.IDENTITY

INSERT INTO Address(Street, City, StateID, Country, ZipCode)
VALUES(@.Street, @.City, @.StateID, @.ZipCode, @.Country)

SET @.AddressID = SCOPE_IDENTITY()

INSERT INTO Phone(PhoneNumber)
VALUES(@.PhoneNumber)

SET @.PhoneID = SCOPE_IDENTITY()

INSERT INTO Company(CompanyName, AddressID, PhoneID)
VALUES(@.CompanyName, @.AddressID, @.PhoneID)

END

The stored procedures are here.

CREATE PROCEDURE GetCompany
(
@.CompanyID INT
)
AS
BEGIN
SELECT CompanyName,Street, City, StateName,
ZipCode, Country, PhoneNumber
FROM
ViewOfCompany
WHERE
CompanyID = @.CompanyID
END
GO

CREATE PROCEDURE AddCompany
(
@.CompanyName VARCHAR(128),
@.Street VARCHAR(256),
@.City VARCHAR(128),
@.StateName VARCHAR(128),
@.ZipCode VARCHAR(128),
@.Country VARCHAR(128),
@.PhoneNumber VARCHAR(32)
)
AS
BEGIN
INSERT INTO ViewOfCompany
VALUES(@.CompanyName, @.Street, @.City, @.StateName,
@.ZipCode, @.Country, @.PhoneNumber)
END
GO

Hi,

first of all you have a misdesign in your trigger. Triggers occur per statement not per row, so inserting 50 rows in a table will fire the trigger only once not 50 times. In your case the trigger is only executed once which means that it would ingnore the 49 other inserted rows. I would first fix that and perhaps come back with the error line where the error you are describing occurs, marking it with something like -- <<-- Error occurs here.

HTH; Jens Suessmeyer.

http:/www.sqlserver2005.de

|||

I am only needing to add one company at a time. In testing the AddCompany stored procedure with Query Analyzer, it appears to work with the correct parameters. For example,

-- Insert First Company
EXEC AddCompany '', '', '', ...

-- Insert Second Company
EXEC AddCompany '', '', '', ...

With actual values, the records are inserted in the tables.

But, my delimma is in the AddCompany stored procedure I don't want to have to pass in a value for the identity column and I don't want to remove it from the view because I need it for the GetCompany stored procedure. And, I don't want to have to create a seperate view for each scenerio; so, my question is there anyway to achieve the desired goal.

I have been looking at the "check" and "no check" options, but I am not sure how they function.

Wednesday, March 7, 2012

Problem with zero value

I have this expression:
=Iif(max( Fields!xpto.Value)=0,"--",1/max( Fields!xpto.Value))
My problem is there when Fields!xpto.Value) is 0 then give me the
folling error:
"The value expression for the textbox 'textbox36' contains an error:
Attempted to divide by zero."
and appear #Error in the report. How can I solve this problem?
Best Regards,
PedroI usually like to put a function in the Report level (Report
properties-->Code tab) code to handle divide by zero. It looks something
like this:
Public Function CalcAvg(dblNum As Double, dblDen As Double) as Object
if (dblDen = nothing) or (dblDen = 0)
CalcAvg = 0
else
CalcAvg = dblNum / dblDen
end if
End Function
From within my report, I call it like this
=Code.CalcAvg(Fields!field1.value, Fields!field2.value)
Hope this helps
Andy Potter
blog : http://sqlreportingservices.spaces.live.com
info@.(NOSPAM)lakeclaireenterprises.com
<pedro.geraldes@.netvisao.pt> wrote in message
news:1175601733.774876.255550@.p15g2000hsd.googlegroups.com...
>I have this expression:
> =Iif(max( Fields!xpto.Value)=0,"--",1/max( Fields!xpto.Value))
> My problem is there when Fields!xpto.Value) is 0 then give me the
> folling error:
> "The value expression for the textbox 'textbox36' contains an error:
> Attempted to divide by zero."
> and appear #Error in the report. How can I solve this problem?
> Best Regards,
> Pedro
>|||Works fine.
Thanks!
On Apr 3, 2:29 pm, "Andy Potter" <i...@.lakeclaireenterprises.com>
wrote:
> I usually like to put a function in the Report level (Report
> properties-->Code tab) code to handle divide by zero. It looks something
> like this:
> Public Function CalcAvg(dblNum As Double, dblDen As Double) as Object
> if (dblDen = nothing) or (dblDen = 0)
> CalcAvg = 0
> else
> CalcAvg = dblNum / dblDen
> end if
> End Function
> From within my report, I call it like this
> =Code.CalcAvg(Fields!field1.value, Fields!field2.value)
> Hope this helps
> --
> Andy Potter
> blog :http://sqlreportingservices.spaces.live.com
> info@.(NOSPAM)lakeclaireenterprises.com<pedro.geral...@.netvisao.pt> wrote in message
> news:1175601733.774876.255550@.p15g2000hsd.googlegroups.com...
>
> >I have this expression:
> > =Iif(max( Fields!xpto.Value)=0,"--",1/max( Fields!xpto.Value))
> > My problem is there when Fields!xpto.Value) is 0 then give me the
> > folling error:
> > "The value expression for the textbox 'textbox36' contains an error:
> > Attempted to divide by zero."
> > and appear #Error in the report. How can I solve this problem?
> > Best Regards,
> > Pedro- Hide quoted text -
> - Show quoted text -

problem with xml data source

hi,

i have a problem:

i got a report to which i pass a xml string like

<xml>

<somedata>

<somemoredata>

value

</somemoredata>

</somedata>

</xml>

in the visual studio it works just the way its supposed to be, but if i upload it on a report server and execute it there nothing happens. even no exception is thrown. the screen remains blank.

anyone got a solution or atleast a hint?

tia

found the problem:

the string i pass is only allowed to be about 1800 bytes large

Saturday, February 25, 2012

Problem with variables

Hi,

I'm new to ssis and unfortunatly I'm having problems already. I'm trying to set a value to a variable in a Script Component using the following code:

Private Sub WriteVariable(ByVal varName As String, ByVal varValue As Object)
Try

Dim vars As IDTSVariables90
Me.VariableDispenser.LockForWrite(varName, vars)
Me.VariableDispenser.GetVariables(vars)
Try
vars(varName).Value = varValue
Catch ex As Exception
Throw ex
Finally
vars.Unlock()
End Try
Catch ex As Exception
Throw ex
End Try
End Sub

It runs without any trouble and no errors. I've made several tests on the input variable and it's just fine. At the end the destination variable does not change. Everyone who is using that code does not complain.

The destination variable is a date ant it is writable.

Any ideia of what is happening or any alternative sugestion?

Thank you in advance

Variables are re-set to their original values after package execution. You can monitor their values during run-time by adding a breakpoint and putting a watch on the variable.

|||

Try using these function !! It may solve u r problem...

Private Function writeVariable(ByVal varName As String, ByVal value As String) As Object

Dim result As Object

Try

Dim vars As Variables

Dts.VariableDispenser.LockOneForWrite(varName, vars)

Try

vars(varName).Value = value

result = vars(varName).Value

Catch ex As Exception

Throw ex

Finally

vars.Unlock()

End Try

Catch ex As Exception

Throw ex

End Try

Return result

End Function

Private Function readVariable(ByVal varName As String) As Object

Dim result As Object

Try

Dim vars As Variables

Dts.VariableDispenser.LockForRead(varName)

Dts.VariableDispenser.GetVariables(vars)

Try

result = vars(varName).Value

Catch ex As Exception

Throw ex

Finally

vars.Unlock()

End Try

Catch ex As Exception

Throw ex

End Try

Return result

End Function

Dev

|||Thank you both very much. I will try to do as you suggest.
|||

Anthony Martin wrote:

Variables are re-set to their original values after package execution.

Correct in what you see, but a bit of while lie, as there is no explicit reset, there is just no Save of the package state. The instance of the package that is executing is just thrown away at the end, so you never see what happened unless you ask, breakpoints etc

It is perhaps most confusing when in the designer and executing a package, that you cannot just examine a variable value when you feel like it, and the values are not there to view at the end of execution. The simple reason for this is that the instance in the designer is not actually the instance being executed, as the designer itself cannot execute a package. You'll notice that as part of execution a package is saved. This is because it needs to be saved, so it can be loaded by the debug host, an entirely separate process that needs to load the package from scratch. This debug host (dtsdebughost.exe) is what really runs the package for us, and it then sends little messages to the designer so we can see what is going on, and get the pretty colours and numbers. Similarly if we look at a variable value in the designer, even whilst a package is executing, we are looking at an offline copy. To see the real live copy in the debug host we need to use the Watch window and a breakpoint, so that the designer can ask explicitly for the current value.

Does that make sense?

|||It makes a lot of sense Anthony. Maybe my code worked but I just could not see the change. I looked at the package explorer and it kept it's original value.

I feel a little embarassed for making you guys waste your time with something so trivial.
Again, thank you.
|||(Darren?) A common mistake, I know I made it. It is confusing, and certainly not immediately obvious as what you see all appears OK on the surface, just the values being wrong! Not a waste of time at all to ask.

Problem with variables

Hi,

I'm new to ssis and unfortunatly I'm having problems already. I'm trying to set a value to a variable in a Script Component using the following code:

Private Sub WriteVariable(ByVal varName As String, ByVal varValue As Object)
Try

Dim vars As IDTSVariables90
Me.VariableDispenser.LockForWrite(varName, vars)
Me.VariableDispenser.GetVariables(vars)
Try
vars(varName).Value = varValue
Catch ex As Exception
Throw ex
Finally
vars.Unlock()
End Try
Catch ex As Exception
Throw ex
End Try
End Sub

It runs without any trouble and no errors. I've made several tests on the input variable and it's just fine. At the end the destination variable does not change. Everyone who is using that code does not complain.

The destination variable is a date ant it is writable.

Any ideia of what is happening or any alternative sugestion?

Thank you in advance

Variables are re-set to their original values after package execution. You can monitor their values during run-time by adding a breakpoint and putting a watch on the variable.

|||

Try using these function !! It may solve u r problem...

Private Function writeVariable(ByVal varName As String, ByVal value As String) As Object

Dim result As Object

Try

Dim vars As Variables

Dts.VariableDispenser.LockOneForWrite(varName, vars)

Try

vars(varName).Value = value

result = vars(varName).Value

Catch ex As Exception

Throw ex

Finally

vars.Unlock()

End Try

Catch ex As Exception

Throw ex

End Try

Return result

End Function

Private Function readVariable(ByVal varName As String) As Object

Dim result As Object

Try

Dim vars As Variables

Dts.VariableDispenser.LockForRead(varName)

Dts.VariableDispenser.GetVariables(vars)

Try

result = vars(varName).Value

Catch ex As Exception

Throw ex

Finally

vars.Unlock()

End Try

Catch ex As Exception

Throw ex

End Try

Return result

End Function

Dev

|||Thank you both very much. I will try to do as you suggest.
|||

Anthony Martin wrote:

Variables are re-set to their original values after package execution.

Correct in what you see, but a bit of while lie, as there is no explicit reset, there is just no Save of the package state. The instance of the package that is executing is just thrown away at the end, so you never see what happened unless you ask, breakpoints etc

It is perhaps most confusing when in the designer and executing a package, that you cannot just examine a variable value when you feel like it, and the values are not there to view at the end of execution. The simple reason for this is that the instance in the designer is not actually the instance being executed, as the designer itself cannot execute a package. You'll notice that as part of execution a package is saved. This is because it needs to be saved, so it can be loaded by the debug host, an entirely separate process that needs to load the package from scratch. This debug host (dtsdebughost.exe) is what really runs the package for us, and it then sends little messages to the designer so we can see what is going on, and get the pretty colours and numbers. Similarly if we look at a variable value in the designer, even whilst a package is executing, we are looking at an offline copy. To see the real live copy in the debug host we need to use the Watch window and a breakpoint, so that the designer can ask explicitly for the current value.

Does that make sense?

|||It makes a lot of sense Anthony. Maybe my code worked but I just could not see the change. I looked at the package explorer and it kept it's original value.

I feel a little embarassed for making you guys waste your time with something so trivial.
Again, thank you.
|||(Darren?) A common mistake, I know I made it. It is confusing, and certainly not immediately obvious as what you see all appears OK on the surface, just the values being wrong! Not a waste of time at all to ask.

Monday, February 20, 2012

problem with updateing foreign key to null value

Hi,
I was wondering if anyone out there can help me with the following problem:
I've written an annotated XSD for retrieving some related tables from
sql-server.
It's used in an XPATH Query that populates a strongly typed dataset
(generated using xsd.exe).
So far everyting works like a dream!
There is however one nagging problem i've encounterd so far. I'm trying to
"deassign" a child from it's parent by updating it's foreign key field to
null (by using the setnull method generated by xsd.exe).
The dataset records this but when I use it to try to update the database, no
update statements are executed and no errors are raised.
Updated the child with a different parent key does however work!!!
So it would seem SQLXML doesn't detect a change when updating to null?!
Any help would be greatly appreciated.
Regards, Rob HuibersHi Rob,
It is not clear which SQLXML API you are using? Are you using
SqlXmlAdapter and its Update method? Is it possible to post your schema so
that I can try to repro the issue here.
Thank you,
Amar Nalla
This posting is provided "AS IS" with no warranties, and confers no rights.
"Rob Huibers" <Rob Huibers@.discussions.microsoft.com> wrote in message
news:E482DAFF-76A7-4A88-993C-A75DB20C5954@.microsoft.com...
> Hi,
> I was wondering if anyone out there can help me with the following
problem:
> I've written an annotated XSD for retrieving some related tables from
> sql-server.
> It's used in an XPATH Query that populates a strongly typed dataset
> (generated using xsd.exe).
> So far everyting works like a dream!
> There is however one nagging problem i've encounterd so far. I'm trying to
> "deassign" a child from it's parent by updating it's foreign key field to
> null (by using the setnull method generated by xsd.exe).
> The dataset records this but when I use it to try to update the database,
no
> update statements are executed and no errors are raised.
> Updated the child with a different parent key does however work!!!
> So it would seem SQLXML doesn't detect a change when updating to null?!
> Any help would be greatly appreciated.
> Regards, Rob Huibers|||Hi Amar,
Thanks for looking into the problem.
You're right in that I'm using SqlXmlAdapter.Update (SQLXML 3.0 sp3).
I've included the schema. The element I'm trying to nullify is
"sub_claim_id" belonging to parent "xyz_assigned_part_claim".
As I've mentioned before, the dataset record records the change but does not
serialize it to the database. When I generate an XmlDataDocument from the
dataset the sub_claim_id" element does not exist anymore. I would have
expected the element appearing with the "xsi:nil" attribute.
Hope you can figure it out, regards, Rob
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:codegen="urn:schemas-microsoft-com:xml-msprop">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="ClaimSubclaims" parent="xyz_claim"
parent-key="claim_id" child="xyz_sub_claim"
child-key="claim_id" />
<sql:relationship name="ClaimSubclaimPartclaims" parent="xyz_sub_claim"
parent-key="sub_claim_id"
child="xyz_part_claim" child-key="sub_claim_id" />
<sql:relationship name="ClaimPartclaims" parent="xyz_claim"
parent-key="claim_id" child="xyz_part_claim"
child-key="claim_id" />
<sql:relationship name="ClaimTasks" parent="xyz_claim"
parent-key="claim_id" child="xyz_task"
child-key="claim_id" />
<sql:relationship name="SubclaimTasks" parent="xyz_sub_claim"
parent-key="sub_claim_id" child="xyz_task"
child-key="sub_claim_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType name="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="part_claim_id" sql:field="part_claim_id"
type="xsd:int" sql:identity="ignore" />
<xsd:element name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:element name="sub_claim_id" sql:field="sub_claim_id" type="xsd:int"
nillable="true" minOccurs="1" />
<xsd:element name="description" sql:field="description" type="xsd:string"
/>
</xsd:sequence>
</xsd:complexType>
<xsd:attributeGroup name="xyz_part_claim_investigation_type">
<xsd:attribute name="part_claim_investigation_id"
sql:field="part_claim_investigation_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="part_claim_id" sql:field="part_claim_id"
type="xsd:int" />
<xsd:attribute name="investigation_id" sql:field="investigation_id"
type="xsd:int" />
</xsd:attributeGroup>
<xsd:attributeGroup name="xyz_investigation_type">
<xsd:attribute name="investigation_id" sql:field="investigation_id"
type="xsd:int" sql:identity="ignore" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:attributeGroup>
<xsd:attributeGroup name="xyz_task_type">
<xsd:attribute name="task_id" sql:field="task_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="type" sql:field="type" type="xsd:int" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
<xsd:attribute name="creator" sql:field="creator" type="xsd:string" />
<xsd:attribute name="performer" sql:field="performer" type="xsd:string" />
<xsd:attribute name="status" sql:field="status" type="xsd:int" />
<xsd:attribute name="date_started" sql:field="date_started"
type="xsd:dateTime" />
<xsd:attribute name="date_closed" sql:field="date_closed"
type="xsd:dateTime" />
<xsd:attribute name="date_created" sql:field="date_created"
type="xsd:dateTime" />
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:attribute name="sub_claim_id" sql:field="sub_claim_id" type="xsd:int"
/>
</xsd:attributeGroup>
<xsd:element name="xyz_claims" sql:is-constant="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_claim" sql:key-fields="claim_id"
sql:relation="xyz_claim">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_claim_task" sql:key-fields="task_id"
sql:relation="xyz_task" sql:relationship="ClaimTasks"
sql:limit-field="sub_claim_id">
<xsd:complexType>
<xsd:attributeGroup ref="xyz_task_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_sub_claim" sql:key-fields="sub_claim_id"
sql:relation="xyz_sub_claim"
sql:relationship="ClaimSubclaims">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_sub_claim_task" sql:key-fields="task_id"
sql:relation="xyz_task"
sql:relationship="SubclaimTasks">
<xsd:complexType>
<xsd:attributeGroup ref="xyz_task_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_assigned_part_claim"
sql:key-fields="part_claim_id" sql:relation="xyz_part_claim"
sql:relationship="ClaimSubclaimPartclaims">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="xyz_investigation"
sql:key-fields="investigation_id" sql:relation="xyz_investigation">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship parent="xyz_part_claim"
parent-key="part_claim_id" child="xyz_part_claim_investigation"
child-key="part_claim_id" />
<sql:relationship parent="xyz_part_claim_investigation"
parent-key="investigation_id" child="xyz_investigation"
child-key="investigation_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup
ref="xyz_investigation_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="sub_claim_id" sql:field="sub_claim_id"
type="xsd:int" sql:identity="ignore" />
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_unassigned_part_claim"
sql:key-fields="part_claim_id" sql:relation="xyz_part_claim"
sql:relationship="ClaimPartclaims" sql:limit-field="sub_claim_id">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="xyz_unassigned_investigation"
sql:key-fields="investigation_id" sql:relation="xyz_investigation">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship parent="xyz_part_claim"
parent-key="part_claim_id" child="xyz_part_claim_investigation"
child-key="part_claim_id" />
<sql:relationship parent="xyz_part_claim_investigation"
parent-key="investigation_id" child="xyz_investigation"
child-key="investigation_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup
ref="xyz_investigation_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
"Amar Nalla [MS]" wrote:

> Hi Rob,
> It is not clear which SQLXML API you are using? Are you using
> SqlXmlAdapter and its Update method? Is it possible to post your schema so
> that I can try to repro the issue here.
> Thank you,
> Amar Nalla
> This posting is provided "AS IS" with no warranties, and confers no rights
.
> "Rob Huibers" <Rob Huibers@.discussions.microsoft.com> wrote in message
> news:E482DAFF-76A7-4A88-993C-A75DB20C5954@.microsoft.com...
> problem:
> no
>
>

problem with updateing foreign key to null value

Hi,
I was wondering if anyone out there can help me with the following problem:
I've written an annotated XSD for retrieving some related tables from
sql-server.
It's used in an XPATH Query that populates a strongly typed dataset
(generated using xsd.exe).
So far everyting works like a dream!
There is however one nagging problem i've encounterd so far. I'm trying to
"deassign" a child from it's parent by updating it's foreign key field to
null (by using the setnull method generated by xsd.exe).
The dataset records this but when I use it to try to update the database, no
update statements are executed and no errors are raised.
Updated the child with a different parent key does however work!!!
So it would seem SQLXML doesn't detect a change when updating to null?!
Any help would be greatly appreciated.
Regards, Rob Huibers
Hi Rob,
It is not clear which SQLXML API you are using? Are you using
SqlXmlAdapter and its Update method? Is it possible to post your schema so
that I can try to repro the issue here.
Thank you,
Amar Nalla
This posting is provided "AS IS" with no warranties, and confers no rights.
"Rob Huibers" <Rob Huibers@.discussions.microsoft.com> wrote in message
news:E482DAFF-76A7-4A88-993C-A75DB20C5954@.microsoft.com...
> Hi,
> I was wondering if anyone out there can help me with the following
problem:
> I've written an annotated XSD for retrieving some related tables from
> sql-server.
> It's used in an XPATH Query that populates a strongly typed dataset
> (generated using xsd.exe).
> So far everyting works like a dream!
> There is however one nagging problem i've encounterd so far. I'm trying to
> "deassign" a child from it's parent by updating it's foreign key field to
> null (by using the setnull method generated by xsd.exe).
> The dataset records this but when I use it to try to update the database,
no
> update statements are executed and no errors are raised.
> Updated the child with a different parent key does however work!!!
> So it would seem SQLXML doesn't detect a change when updating to null?!
> Any help would be greatly appreciated.
> Regards, Rob Huibers
|||Hi Amar,
Thanks for looking into the problem.
You're right in that I'm using SqlXmlAdapter.Update (SQLXML 3.0 sp3).
I've included the schema. The element I'm trying to nullify is
"sub_claim_id" belonging to parent "xyz_assigned_part_claim".
As I've mentioned before, the dataset record records the change but does not
serialize it to the database. When I generate an XmlDataDocument from the
dataset the sub_claim_id" element does not exist anymore. I would have
expected the element appearing with the "xsi:nil" attribute.
Hope you can figure it out, regards, Rob
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:codegen="urn:schemas-microsoft-com:xml-msprop">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="ClaimSubclaims" parent="xyz_claim"
parent-key="claim_id" child="xyz_sub_claim"
child-key="claim_id" />
<sql:relationship name="ClaimSubclaimPartclaims" parent="xyz_sub_claim"
parent-key="sub_claim_id"
child="xyz_part_claim" child-key="sub_claim_id" />
<sql:relationship name="ClaimPartclaims" parent="xyz_claim"
parent-key="claim_id" child="xyz_part_claim"
child-key="claim_id" />
<sql:relationship name="ClaimTasks" parent="xyz_claim"
parent-key="claim_id" child="xyz_task"
child-key="claim_id" />
<sql:relationship name="SubclaimTasks" parent="xyz_sub_claim"
parent-key="sub_claim_id" child="xyz_task"
child-key="sub_claim_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType name="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="part_claim_id" sql:field="part_claim_id"
type="xsd:int" sql:identity="ignore" />
<xsd:element name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:element name="sub_claim_id" sql:field="sub_claim_id" type="xsd:int"
nillable="true" minOccurs="1" />
<xsd:element name="description" sql:field="description" type="xsd:string"
/>
</xsd:sequence>
</xsd:complexType>
<xsd:attributeGroup name="xyz_part_claim_investigation_type">
<xsd:attribute name="part_claim_investigation_id"
sql:field="part_claim_investigation_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="part_claim_id" sql:field="part_claim_id"
type="xsd:int" />
<xsd:attribute name="investigation_id" sql:field="investigation_id"
type="xsd:int" />
</xsd:attributeGroup>
<xsd:attributeGroup name="xyz_investigation_type">
<xsd:attribute name="investigation_id" sql:field="investigation_id"
type="xsd:int" sql:identity="ignore" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:attributeGroup>
<xsd:attributeGroup name="xyz_task_type">
<xsd:attribute name="task_id" sql:field="task_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="type" sql:field="type" type="xsd:int" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
<xsd:attribute name="creator" sql:field="creator" type="xsd:string" />
<xsd:attribute name="performer" sql:field="performer" type="xsd:string" />
<xsd:attribute name="status" sql:field="status" type="xsd:int" />
<xsd:attribute name="date_started" sql:field="date_started"
type="xsd:dateTime" />
<xsd:attribute name="date_closed" sql:field="date_closed"
type="xsd:dateTime" />
<xsd:attribute name="date_created" sql:field="date_created"
type="xsd:dateTime" />
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:attribute name="sub_claim_id" sql:field="sub_claim_id" type="xsd:int"
/>
</xsd:attributeGroup>
<xsd:element name="xyz_claims" sql:is-constant="true">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_claim" sql:key-fields="claim_id"
sql:relation="xyz_claim">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_claim_task" sql:key-fields="task_id"
sql:relation="xyz_task" sql:relationship="ClaimTasks"
sql:limit-field="sub_claim_id">
<xsd:complexType>
<xsd:attributeGroup ref="xyz_task_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_sub_claim" sql:key-fields="sub_claim_id"
sql:relation="xyz_sub_claim"
sql:relationship="ClaimSubclaims">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="xyz_sub_claim_task" sql:key-fields="task_id"
sql:relation="xyz_task"
sql:relationship="SubclaimTasks">
<xsd:complexType>
<xsd:attributeGroup ref="xyz_task_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_assigned_part_claim"
sql:key-fields="part_claim_id" sql:relation="xyz_part_claim"
sql:relationship="ClaimSubclaimPartclaims">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="xyz_investigation"
sql:key-fields="investigation_id" sql:relation="xyz_investigation">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship parent="xyz_part_claim"
parent-key="part_claim_id" child="xyz_part_claim_investigation"
child-key="part_claim_id" />
<sql:relationship parent="xyz_part_claim_investigation"
parent-key="investigation_id" child="xyz_investigation"
child-key="investigation_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup
ref="xyz_investigation_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="sub_claim_id" sql:field="sub_claim_id"
type="xsd:int" sql:identity="ignore" />
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="xyz_unassigned_part_claim"
sql:key-fields="part_claim_id" sql:relation="xyz_part_claim"
sql:relationship="ClaimPartclaims" sql:limit-field="sub_claim_id">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="xyz_part_claim_type">
<xsd:sequence>
<xsd:element name="xyz_unassigned_investigation"
sql:key-fields="investigation_id" sql:relation="xyz_investigation">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship parent="xyz_part_claim"
parent-key="part_claim_id" child="xyz_part_claim_investigation"
child-key="part_claim_id" />
<sql:relationship parent="xyz_part_claim_investigation"
parent-key="investigation_id" child="xyz_investigation"
child-key="investigation_id" />
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup
ref="xyz_investigation_type"></xsd:attributeGroup>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="claim_id" sql:field="claim_id" type="xsd:int"
sql:identity="ignore" />
<xsd:attribute name="description" sql:field="description"
type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
"Amar Nalla [MS]" wrote:

> Hi Rob,
> It is not clear which SQLXML API you are using? Are you using
> SqlXmlAdapter and its Update method? Is it possible to post your schema so
> that I can try to repro the issue here.
> Thank you,
> Amar Nalla
> This posting is provided "AS IS" with no warranties, and confers no rights.
> "Rob Huibers" <Rob Huibers@.discussions.microsoft.com> wrote in message
> news:E482DAFF-76A7-4A88-993C-A75DB20C5954@.microsoft.com...
> problem:
> no
>
>