Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataSet readonly from a stored procedure
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Environment versions
Environment:
C# 4.0
Database:
MS SQL Server
Miscellaneous
Thread ID:
01489891
Message ID:
01490185
Views:
69
>>>Hi Bonnie,
>>> I would say that all the columns are causing the problem. When I step through, the ReadOnly attribute is false on all columns of the DataTable (except for the Primary Key) until I hit the following code:
>>>
>>>// Fill the specified table in the DataSet
>>>adapter.Fill(ds, tableName);
>>>
>>>After this line runs, all the columns in the DataTable switch to ReadOnly = true (for the offending stored procedure that is)
>>>
>>>
>>>Don
>>
>>Have you tried to not use Dynamic SQL in this SP? Someone mentioned today that dynamic SQL may cause this problem and I think it's very likely to be the cause.
>>
>>(BTW, funny - I used 'cause' twice in the same sentence - once as a verb and once as a noun)
>
>
>Naomi,
> I think that the code that Tim originally posted was not the final solution that we used for retrieving the data. Here is what I am using that is providing the offending data. Am I missing some Dynamic SQL stuck in here?:
>
>CREATE PROCEDURE [dbo].[AppointmentsSelectByListOfTeachers_StudentID]
> @TeacherIDs varchar(MAX),
> @StudentID char(11) = NULL
>AS
>BEGIN
> (SELECT apt.[ID],
> apt.[Subject],
> apt.[Description],
> apt.[Start],
> apt.[End],
> apt.[TeacherID],
> apt.[RecurrenceRule],
> apt.[RecurrenceParentID]
> FROM [dbo].[Appointments] apt INNER JOIN [dbo].[fnSplit](@TeacherIDs, ',') F
> on TeacherID = F.Value)
> UNION -- to remove duplicates
> (SELECT A.[ID],
> A.[Subject],
> A.[Description],
> A.[Start],
> A.[End],
> A.[TeacherID],
> A.[RecurrenceRule],
> A.[RecurrenceParentID]
> FROM [dbo].[Appointments] A
> where exists (select 1 from [Joint_StudID_ApptID] stud
> where stud.AppointmentID = A.ID and stud.StudentID = @StudentID))
>END
>
>/***************************************************************************/
>
>CREATE FUNCTION [dbo].[fnSplit]
>(@list VARCHAR(8000),
>@delim CHAR(1) = ','
>) RETURNS TABLE AS
>RETURN
> WITH csvtbl(START, stop) AS (
> SELECT START = 1,
> stop = CHARINDEX(@delim COLLATE Slovenian_BIN2, @list + @delim)
> UNION ALL
> SELECT START = stop + 1,
> stop = CHARINDEX(@delim COLLATE Slovenian_BIN2,
> @list + @delim, stop + 1)
> FROM csvtbl
> WHERE stop > 0
> )
> SELECT row_number() over (order by Start) as ID, LTRIM(RTRIM(SUBSTRING(@list, START,
> CASE WHEN stop > 0 THEN stop - START ELSE 0 END)))
> AS VALUE
> FROM csvtbl
> WHERE stop > 0
>
>GO
>
>Thanks!
>
>Don
>ps. This is my first time posting on UT. Should I not be checking these boxes here at the bottom "Forward a copy of this reply to
>these members" ? What is the protocol?

Hi Don,

This code seems to be fine and it does not use Dynamic SQL, so I'm not sure why would it give you this problem.

As for the rule about checking the box at the bottom - you can use it as you see fit. If you think that all thread participants may want to have a copy of this message, then you'll check this box. Otherwise it's better to not check it. If in doubt, better to not check it also.

Also, when you post code in UT, use PRE tags, e.g. < PRE > at the beginning and < / PRE > at the end (but without spaces).
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform