F
fniles
Today, I did an UPDATE statement on SQL Server Management Studio on a few
records.
Now, from a VB.NET program when I tried to get those records that I updated,
when I go thru the datareader, when it gets around those records that I
updated, it timed out.
Even though getting the same query thru SQL Server Management Studio is very
fast.
What can I do to fix it ?
Thank you.
This is the UPDATE statement that I did
UPDATE tickdata1min set openprice = openprice *10,highprice = highprice *10,
lowprice = lowprice *10,closeprice = closeprice *10 where symbol = 'YMM0'
AND SEQUENCENUMBER >= '20100511-0950'
AND SEQUENCENUMBER <= '20100511-1038' AND CLOSEPRICE < 100
This is the Stored Procedure that I use
exec GetData1Min @Symbol='YMM0',@SeqNumLow='20100511-1000'
Using command = New SqlCommand(sql, connection)
Dim reader As SqlDataReader
command.CommandType = CommandType.Text
command.CommandTimeout = 300
reader = command.ExecuteReader()
While reader.Read
outputData = ""
currentSequenceNumber = reader(0) -> timed out when it gets to
SEQUENCENUMBER >= '20100511-0844'
If I do
exec GetData1Min @Symbol='YMM0',@SeqNumLow='20100511-1040', it won't timed
out.
If I do GetData1Min for other symbols that I didn't update today, it won't
timed out.
It only timed out on the symbols that I did an "UPDATE" statement thru SQL
Server Management Studio.
************************************************************************************************
This is the table
CREATE TABLE [dbo].[TickData1Min](
[SequenceNumber] [char](13) NOT NULL,
[CommodityCode] [char](10) NOT NULL,
[MonthYear] [char](2) NULL,
[Symbol] [char](12) NOT NULL,
[OpenPrice] [decimal](16, 4) NULL,
[HighPrice] [decimal](16, 4) NULL,
[LowPrice] [decimal](16, 4) NULL,
[ClosePrice] [decimal](16, 4) NULL,
[Volume] [numeric](18, 0) NULL CONSTRAINT [DF_TickData1Min_Volume] DEFAULT
((0)),
[Date] [datetime] NULL,
CONSTRAINT [PK_TickData1Min] PRIMARY KEY CLUSTERED
(
[Symbol] ASC,
[SequenceNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
This is the Stored Procedure
ALTER Procedure [dbo].[GetData1Min]
(
@Symbol VarChar(10),
@SeqNumLow VarChar(13)
)
as Begin
Select sequencenumber, openprice,highprice,lowprice,closeprice,volume
From TickData1Min
Where [Symbol] = @Symbol
AND SequenceNumber >= @SeqNumLow
Order By SequenceNumber
OPTION (RECOMPILE)
End
records.
Now, from a VB.NET program when I tried to get those records that I updated,
when I go thru the datareader, when it gets around those records that I
updated, it timed out.
Even though getting the same query thru SQL Server Management Studio is very
fast.
What can I do to fix it ?
Thank you.
This is the UPDATE statement that I did
UPDATE tickdata1min set openprice = openprice *10,highprice = highprice *10,
lowprice = lowprice *10,closeprice = closeprice *10 where symbol = 'YMM0'
AND SEQUENCENUMBER >= '20100511-0950'
AND SEQUENCENUMBER <= '20100511-1038' AND CLOSEPRICE < 100
This is the Stored Procedure that I use
exec GetData1Min @Symbol='YMM0',@SeqNumLow='20100511-1000'
Using command = New SqlCommand(sql, connection)
Dim reader As SqlDataReader
command.CommandType = CommandType.Text
command.CommandTimeout = 300
reader = command.ExecuteReader()
While reader.Read
outputData = ""
currentSequenceNumber = reader(0) -> timed out when it gets to
SEQUENCENUMBER >= '20100511-0844'
If I do
exec GetData1Min @Symbol='YMM0',@SeqNumLow='20100511-1040', it won't timed
out.
If I do GetData1Min for other symbols that I didn't update today, it won't
timed out.
It only timed out on the symbols that I did an "UPDATE" statement thru SQL
Server Management Studio.
************************************************************************************************
This is the table
CREATE TABLE [dbo].[TickData1Min](
[SequenceNumber] [char](13) NOT NULL,
[CommodityCode] [char](10) NOT NULL,
[MonthYear] [char](2) NULL,
[Symbol] [char](12) NOT NULL,
[OpenPrice] [decimal](16, 4) NULL,
[HighPrice] [decimal](16, 4) NULL,
[LowPrice] [decimal](16, 4) NULL,
[ClosePrice] [decimal](16, 4) NULL,
[Volume] [numeric](18, 0) NULL CONSTRAINT [DF_TickData1Min_Volume] DEFAULT
((0)),
[Date] [datetime] NULL,
CONSTRAINT [PK_TickData1Min] PRIMARY KEY CLUSTERED
(
[Symbol] ASC,
[SequenceNumber] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
This is the Stored Procedure
ALTER Procedure [dbo].[GetData1Min]
(
@Symbol VarChar(10),
@SeqNumLow VarChar(13)
)
as Begin
Select sequencenumber, openprice,highprice,lowprice,closeprice,volume
From TickData1Min
Where [Symbol] = @Symbol
AND SequenceNumber >= @SeqNumLow
Order By SequenceNumber
OPTION (RECOMPILE)
End