L
larzeb
Kevin,
The timeout occurs while executing the daDetail.Update statement. I changed the SqlDataAdapter
constructors to point to new Select commands. This did not correct the timeout problem. I included
the Update command's stored procedure and create table ddl.
Thanks, Lars
Dim cn As New SqlConnection(ConnectionSettings.cnString)
Dim daMaster As New SqlDataAdapter(Me.CreateSelectMaster(cn))
Dim daDetail As New SqlDataAdapter(Me.CreateSelectDetail(cn))
Dim tblMaster As DataTable = ds.Tables(0)
Dim tblDetail As DataTable = ds.Tables(1)
daMaster.InsertCommand = Me.CreateInsertCommandUse(cn)
daMaster.UpdateCommand = Me.CreateUpdateCommandUse(cn)
daMaster.DeleteCommand = Me.CreateDeleteCommandUse(cn)
daDetail.InsertCommand = Me.CreateInsertUpdateCommandMap(cn)
daDetail.UpdateCommand = Me.CreateInsertUpdateCommandMap(cn)
daDetail.DeleteCommand = Me.CreateDeleteCommandMap(cn)
cn.Open()
Try
' Submit the only new Master/Detail rows
daMaster.Update(tblMaster.Select(Nothing, Nothing, DataViewRowState.Added))
==> daDetail.Update(tblDetail.Select(Nothing, Nothing, DataViewRowState.Added))
Private Function CreateSelectMaster(ByVal cn As SqlConnection) As SqlCommand
Dim cmd As New SqlCommand("usp_UnivUseCode_Sell_All", cn)
cmd.CommandType = CommandType.StoredProcedure
Return cmd
End Function
Private Function CreateSelectDetail(ByVal cn As SqlConnection) As SqlCommand
Dim cmd As New SqlCommand("usp_UnivUseCodeMap_Sell_All", cn)
cmd.CommandType = CommandType.StoredProcedure
Return cmd
End Function
CREATE PROCEDURE [dbo].usp_UnivUseCodeMap_Save
@CompID int,
@UseCodeFK int,
@UnivUseCode char(2)
AS
if exists (SELECT * FROM UnivUseCodeMap WHERE CompID = @CompID AND
UseCodeFK = @UseCodeFK)
BEGIN
UPDATE [dbo].[UnivUseCodeMap] SET
[UnivUseCode] = @UnivUseCode
WHERE
[CompID] = @CompID
AND [UseCodeFK] = @UseCodeFK
END
ELSE
BEGIN
INSERT INTO [dbo].[UnivUseCodeMap] (
[CompID],
[UseCodeFK],
[UnivUseCode]
) VALUES (
@CompID,
@UseCodeFK,
@UnivUseCode
)
END
CREATE TABLE [dbo].[UnivUseCodeMap] (
[CompID] [int] NOT NULL,
[UseCodeFK] [int] NOT NULL ,
[UnivUseCode] [char] (2) NOT NULL ,
[DateAdded] [datetime] NOT NULL
The timeout occurs while executing the daDetail.Update statement. I changed the SqlDataAdapter
constructors to point to new Select commands. This did not correct the timeout problem. I included
the Update command's stored procedure and create table ddl.
Thanks, Lars
Dim cn As New SqlConnection(ConnectionSettings.cnString)
Dim daMaster As New SqlDataAdapter(Me.CreateSelectMaster(cn))
Dim daDetail As New SqlDataAdapter(Me.CreateSelectDetail(cn))
Dim tblMaster As DataTable = ds.Tables(0)
Dim tblDetail As DataTable = ds.Tables(1)
daMaster.InsertCommand = Me.CreateInsertCommandUse(cn)
daMaster.UpdateCommand = Me.CreateUpdateCommandUse(cn)
daMaster.DeleteCommand = Me.CreateDeleteCommandUse(cn)
daDetail.InsertCommand = Me.CreateInsertUpdateCommandMap(cn)
daDetail.UpdateCommand = Me.CreateInsertUpdateCommandMap(cn)
daDetail.DeleteCommand = Me.CreateDeleteCommandMap(cn)
cn.Open()
Try
' Submit the only new Master/Detail rows
daMaster.Update(tblMaster.Select(Nothing, Nothing, DataViewRowState.Added))
==> daDetail.Update(tblDetail.Select(Nothing, Nothing, DataViewRowState.Added))
Private Function CreateSelectMaster(ByVal cn As SqlConnection) As SqlCommand
Dim cmd As New SqlCommand("usp_UnivUseCode_Sell_All", cn)
cmd.CommandType = CommandType.StoredProcedure
Return cmd
End Function
Private Function CreateSelectDetail(ByVal cn As SqlConnection) As SqlCommand
Dim cmd As New SqlCommand("usp_UnivUseCodeMap_Sell_All", cn)
cmd.CommandType = CommandType.StoredProcedure
Return cmd
End Function
CREATE PROCEDURE [dbo].usp_UnivUseCodeMap_Save
@CompID int,
@UseCodeFK int,
@UnivUseCode char(2)
AS
if exists (SELECT * FROM UnivUseCodeMap WHERE CompID = @CompID AND
UseCodeFK = @UseCodeFK)
BEGIN
UPDATE [dbo].[UnivUseCodeMap] SET
[UnivUseCode] = @UnivUseCode
WHERE
[CompID] = @CompID
AND [UseCodeFK] = @UseCodeFK
END
ELSE
BEGIN
INSERT INTO [dbo].[UnivUseCodeMap] (
[CompID],
[UseCodeFK],
[UnivUseCode]
) VALUES (
@CompID,
@UseCodeFK,
@UnivUseCode
)
END
CREATE TABLE [dbo].[UnivUseCodeMap] (
[CompID] [int] NOT NULL,
[UseCodeFK] [int] NOT NULL ,
[UnivUseCode] [char] (2) NOT NULL ,
[DateAdded] [datetime] NOT NULL