H
Helen
I'm looking for your advice and maybe help with this issue.
So, this is my saga.
1). I got to create a grid, which would look preety much
like an Excel spread sheet. I did it and that's
schematically how it looks (Forget about id for now. It's
Current over New Status):
New Status
id Current Status 010 020 030 040 050
...
1 010 010 020 '030 040 050 ...
2 020 010 020 030 030 030 ...
3 030 040 030 030 040 050 ...
4 040 010 020 180 050 050 ...
5 050 010 020 360 040 050 ...
.... ... ... ... ... ... ... .
2). This grid is a dynamical grid. To do this I had to
create a table. I wrote a SP which "united" 2 tables
which didn't have any keys to unite them. From the SQL
SERVER table tlkpStatus I took all codes to create
a "frame" of my grid, to create just rows' and columns'
headers. Then the content of the grid came from the table
tlkpStatusUpdateRule, ResultStatus column. + Knowing that
SQLCommandBuilder needs the Primary Key, I've created in
my table additional column ("id"). This is my store
procedure to create the whole table:
CREATE PROCEDURE dbo.spx_SummaryStatusUpdate
AS
create table tblSummaryStatus (id int identity primary
key , [Current] varchar(3) not null)
declare @sql varchar(8000)
declare @v char(3)
select @v = ''
while @v < (select max(code) from tlkpStatus)
begin
select @v = min(code) from tlkpStatus where code > @v
select @sql = 'alter table tblSummaryStatus add [' + @v
+ '] char(3) null'
exec (@sql)
end
select @sql = 'insert tblSummaryStatus ([Current]) select
code from tlkpStatus'
exec (@sql)
/* Updating */
select identity(int,1,1) id, i = [CurrentStatus], j =
[NewStatus] into #a from tlkpStatusUpdateRule
declare @id int
select @id = 0
while @id < (select max(id) from #a)
begin
select @id = min(id) from #a where id > @id
select @sql = 'update tblSummaryStatus set [' + j + '] =
ResultStatus from tlkpStatusUpdateRule where
tlkpStatusUpdateRule.[CurrentStatus] =
''' + i + ''' and tlkpStatusUpdateRule.[NewStatus] = ''' +
j + ''' and tblSummaryStatus.[Current] = ''' + i + ''''
from #a where id = @id
exec (@sql)
end
drop table #a
/*end Updating*/
/* Just for my testing purposes
Select * from tblSummaryStatus
Select * from tlkpStatusUpdateRule */
GO
-----------------------------------------------------------
------------
3). Everything works fine here. Now when I make some
changes to the DataSet and click the UPDATE button, I get
this error in VB.NET:
" An unhandled exception of type
System.Data.SqlClient.Exception occurred in
System.data.dll"
And my BREAK point stops here data_adapter.Update
(m_DataSet)
As you recommended, I went to the SQL Server Profile and
traced. I got this Update statement. This is just a
fragment:
"exec sp_executesql N'UPDATE tblSummaryStatus SET 000 =
@p1 WHERE ( (id = @p2) AND ((Current IS NULL AND @p3 IS
NULL) ...."
Instead, it should say:
"exec sp_executesql N'UPDATE tblSummaryStatus SET [000]
= ' @p1' WHERE ( (id = @p2) ..."
Could you please help me and let me know what should I do.
Thank you very much. Appreciate in advance.
Helen.
So, this is my saga.
1). I got to create a grid, which would look preety much
like an Excel spread sheet. I did it and that's
schematically how it looks (Forget about id for now. It's
Current over New Status):
New Status
id Current Status 010 020 030 040 050
...
1 010 010 020 '030 040 050 ...
2 020 010 020 030 030 030 ...
3 030 040 030 030 040 050 ...
4 040 010 020 180 050 050 ...
5 050 010 020 360 040 050 ...
.... ... ... ... ... ... ... .
2). This grid is a dynamical grid. To do this I had to
create a table. I wrote a SP which "united" 2 tables
which didn't have any keys to unite them. From the SQL
SERVER table tlkpStatus I took all codes to create
a "frame" of my grid, to create just rows' and columns'
headers. Then the content of the grid came from the table
tlkpStatusUpdateRule, ResultStatus column. + Knowing that
SQLCommandBuilder needs the Primary Key, I've created in
my table additional column ("id"). This is my store
procedure to create the whole table:
CREATE PROCEDURE dbo.spx_SummaryStatusUpdate
AS
create table tblSummaryStatus (id int identity primary
key , [Current] varchar(3) not null)
declare @sql varchar(8000)
declare @v char(3)
select @v = ''
while @v < (select max(code) from tlkpStatus)
begin
select @v = min(code) from tlkpStatus where code > @v
select @sql = 'alter table tblSummaryStatus add [' + @v
+ '] char(3) null'
exec (@sql)
end
select @sql = 'insert tblSummaryStatus ([Current]) select
code from tlkpStatus'
exec (@sql)
/* Updating */
select identity(int,1,1) id, i = [CurrentStatus], j =
[NewStatus] into #a from tlkpStatusUpdateRule
declare @id int
select @id = 0
while @id < (select max(id) from #a)
begin
select @id = min(id) from #a where id > @id
select @sql = 'update tblSummaryStatus set [' + j + '] =
ResultStatus from tlkpStatusUpdateRule where
tlkpStatusUpdateRule.[CurrentStatus] =
''' + i + ''' and tlkpStatusUpdateRule.[NewStatus] = ''' +
j + ''' and tblSummaryStatus.[Current] = ''' + i + ''''
from #a where id = @id
exec (@sql)
end
drop table #a
/*end Updating*/
/* Just for my testing purposes
Select * from tblSummaryStatus
Select * from tlkpStatusUpdateRule */
GO
-----------------------------------------------------------
------------
3). Everything works fine here. Now when I make some
changes to the DataSet and click the UPDATE button, I get
this error in VB.NET:
" An unhandled exception of type
System.Data.SqlClient.Exception occurred in
System.data.dll"
And my BREAK point stops here data_adapter.Update
(m_DataSet)
As you recommended, I went to the SQL Server Profile and
traced. I got this Update statement. This is just a
fragment:
"exec sp_executesql N'UPDATE tblSummaryStatus SET 000 =
@p1 WHERE ( (id = @p2) AND ((Current IS NULL AND @p3 IS
NULL) ...."
Instead, it should say:
"exec sp_executesql N'UPDATE tblSummaryStatus SET [000]
= ' @p1' WHERE ( (id = @p2) ..."
Could you please help me and let me know what should I do.
Thank you very much. Appreciate in advance.
Helen.