Hello Newsgroup,
I have written a very short program to get information from a whole
table out of a database. the problem is that other people couldn't
work on this table during the process. It seems that my program locks
the whole table.
I used the DataReader from the .NET Framework. Can you please take a
look at the code and give me any solution??? Thank very much, Nils
Dim strSQL As String = "SELECT * FROM TESTTABLE"
Dim Conn As System.Data.Sql Client.SqlConne ction = New
System.Data.Sql Client.SqlConne ction("Data Source=1.1.1.1;
User ID=sa;Password= secret;Persist Security Info=True;
Initial Catalog=TestDB" )
Conn.Open()
Dim SqlCmd As SqlCommand = New SqlCommand(strS QL,Conn)
Dim DR As System.Data.Sql Client.SqlDataR eader
Try
DR = SqlCmd.ExecuteR eader
Do While DR.Read()
<only reading with DR.item("column name")>
Loop
Catch ex As Exception
errorhandler(ex .ToString)
Finally
If DR.IsClosed = False Then DR.Close()
SqlCmd.Dispose( )
End Try
I have written a very short program to get information from a whole
table out of a database. the problem is that other people couldn't
work on this table during the process. It seems that my program locks
the whole table.
I used the DataReader from the .NET Framework. Can you please take a
look at the code and give me any solution??? Thank very much, Nils
Dim strSQL As String = "SELECT * FROM TESTTABLE"
Dim Conn As System.Data.Sql Client.SqlConne ction = New
System.Data.Sql Client.SqlConne ction("Data Source=1.1.1.1;
User ID=sa;Password= secret;Persist Security Info=True;
Initial Catalog=TestDB" )
Conn.Open()
Dim SqlCmd As SqlCommand = New SqlCommand(strS QL,Conn)
Dim DR As System.Data.Sql Client.SqlDataR eader
Try
DR = SqlCmd.ExecuteR eader
Do While DR.Read()
<only reading with DR.item("column name")>
Loop
Catch ex As Exception
errorhandler(ex .ToString)
Finally
If DR.IsClosed = False Then DR.Close()
SqlCmd.Dispose( )
End Try
Comment