I have been developing some small database programs in Visual Studio C# for some time now. I'm presently using Versus 2010. Up to lately all of the applications were went on a single computer the database was saved on and everything went great. Lately I needed to begin to developing some applications which will operate on another computer that's on a single local network.
Simple, however i encounter an issue when running queries to fill controls, like a power grid as well as combo box. However , it will take 15-thirty seconds per control if my totally tugging a lot of data. I understand the reason being the application is delivering out my choose query, waiting its the outcomes to encounter the network after which exhibiting the data. The issue is I'm not sure how to handle it.
Below I've got a code snippet(slightly modified to be preferable). It's utilizing a Firebird database, though I personally use MSSQL and Sybase Advantage too with similar results.
FbConnection fdbConnect = new FbConnection(); fdbConnect.ConnectionString = Program.ConnectionString; fdbConnect.Open(); FbCommand fcmdQuery = new FbCommand(); fcmdQuery.Connection = fdbConnect; fcmdQuery.CommandText = "select dadda.name, yadda.address, yadda.phone1 from SOMETABLE left join yadda on dadda where yadda.pk = dadda.yaddapk"; FbDataAdapter fdaDataSet = new FbDataAdapter(fcmdQuery); DataSet dsReturn = new DataSet(); fdaDataSet.Fill(dsReturn); fdbConnect.Close(); DataGridView1.DataSource = dsReturn.Tables;
Does anybody have suggestions how I'm able to speed this up?
You might coming back unnecessary data for the reason that Choose * statement. It may be inefficient in network traffic and drive lower the performance of the application. You will find many articles relating to this and just how you need to specify your posts clearly. Here's one in particular.
You are able to lessen the amount of the response by restricting your posts:
select * from SOMETABLE
select a,b,c from SOMETABLE
to retrieve just the data you'll need.
Your mileage vary based on exactly what the table consists of. If you will find unused blob posts for example, you're adding a substantial overhead for your response.
If you're exhibiting the information in
gridview, and when information is huge, its easier to do server side paging to ensure that a particular quantity of rows is came back at any given time.