Timeout error when inserting and reading from same table in sql server and .net

O

Omar

Hi All,
I have a headache with SQL Server and .net application which I hope you
can help with.

I have this trigger on my table 'tester' in sql server 2000. It calls
the external program exetest

CREATE TRIGGER testTrig ON [dbo].[tester]
FOR INSERT, UPDATE
AS
exec master..xp_cmdShell 'C:\ExeTest.exe'

I am calling the ExeTest.exe program which is supposed to read from the
same table again and just display first.

I am having a similar problem as this guy below( i.e updating and
reading the same table. But there is no solution)

http://groups.google.com/group/micr...expired+sqldatareader&rnum=1#0494ca46ee4147bb

Is there a way that I can achieve this? Even if it is long, I do not
mind as long as there is no timeout. I have set the timeout to 5
minutes plus, and still got a timeout error. It seems the table is
locked and cannot be selected from???

If you still reading, here is my code in the ExeTest.exe :)

Sub Main()

Dim sqlstring As String = "select * from tester"
'Dim connString1 As String = "Data
Source=servername;Database=ProjectServer;UID=sa;pwd=pwd"
Dim connString1 As String = "Data
Source=localhost;Database=ProjectServer;Integrated Security=true"
Dim conn As New SqlConnection
conn = New SqlConnection(connString1)
Try
conn.Open()
Dim cmd As New SqlCommand(sqlstring, conn)
cmd.CommandTimeout = 40
Dim listA As SqlDataReader = cmd.ExecuteReader()

While listA.Read
Console.WriteLine(listA(1))
End While
'End If
listA.Close()
conn.Close()
Catch ex As Exception
Console.WriteLine("error : " + ex.Message)
End Try

End Sub

Regards,
Omar
 
O

Omar

Hope this helps whoever encounters a similar problem. If all you need
is to just select a record for which you are sure the column that you
want will not be changed(like in my case), you can use the (nolock)
function.

"select column_A , column_B from myTable(nolock) where blah='bleh'"

Enjoy, and do not be frustrated that you have been searching this for
hours :)

Regards,
Omar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top