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:
01490182
Views:
53
>>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?
Ronald D. Edge
Retired from Indiana University Mar 1, 2011

"You've got to be very careful if you don't know where you are going,
because you might not get there."
“When you come to the fork in the road, take it.”
--Yogi Berra
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform