Hello,
I have developed an application to keep some data.
The application is getting data from a SQL Server 2005 which is located in the lan network.
After working for a while the program is suddenly very slow.
When rebooting the PC where the program is running, the problem is gone for a while so I think that I do something wrong with the SQL read and write and so using all the resources.
The program is running on Windows XP Pro SP3 and is written in VB. Net 2008.
This is how i read my data from the SQL Server. Maybe i do something wrong :
Dim cnstandaardinstellingen As New SqlConnection(connectionstring)
Dim cmdstandaardinstellingen As New SqlCommand
cnstandaardinstellingen.Open()
Dim strQuerystandaardinstellingen As String = "select * from instellingen where hotel ='" + hotel + "'"
Dim myCommandstandaardinstellingen As New SqlCommand(strQuerystandaardinstellingen, cnstandaardinstellingen)
Dim myReaderstandaardinstellingen As SqlDataReader = myCommandstandaardinstellingen.ExecuteReader()
myReaderstandaardinstellingen.Read()
hotelnaam = myReaderstandaardinstellingen.GetString(2)
startgroep = myReaderstandaardinstellingen.GetString(20)
ticketprinterport = myReaderstandaardinstellingen.GetString(12)
klantdisplay = myReaderstandaardinstellingen.GetString(21)
myReaderstandaardinstellingen.Close()
cnstandaardinstellingen.Close()
This is how I update some thing in the database :
Dim sql As String = "UPDATE Kamer SET Kamerstatus='1', Tijd='" + DateTime.Now.ToString("MM/dd/yyyy HH:mm") + "' WHERE Kamernummer='" + transferdata + "' and Hotel='" + hotel + "'"
Dim myConnectionb As SqlConnection
Dim myCommandb As SqlCommand
Dim ra As Integer
myConnectionb = New SqlConnection(connectionstring)
myConnectionb.Open()
myCommandb = New SqlCommand(sql, myConnectionb)
ra = myCommandb.ExecuteNonQuery()
myConnectionb.Close()
The Connection string I use :
connectionstring = "Data Source=192.168.0.2;Initial catalog=logeurs;uid=sa;password=password"
So when I read or write, after I have all the data I close the connection.
Can this be causing the problem that I always open and close .
Can anyone give me suggestions on this please.
Thanks
Best regards
Didier