Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Speeding up query
Message
 
To
07/11/2002 11:53:19
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, United States
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00719885
Message ID:
00719897
Views:
13
Jerry,

This is because of connection pooling. First time you run your application, it has to create the pool using the default settings or customized settings if specified in connection string. That incures an overhead, however for subsequent runs, the application just pulls one of the already opened connections, hence it is faster.

You can usually speed the connection time by adding an entry to your hosts file mapping the server name to IP address. This does create a bit of a maintenance problem, but it shaves time off new connection creation. Of course if your servers don't have static IP addresses you won't be able to implement this.

>I have created a C# form to access a VFP table on our network. The following is the code I am using to query this table. Everything works but the speed isn't that good. It takes about 2 seconds to return the result. The same query in VFP is immediate.
>
>The oConn.Open(); and the oDataAdapter.Fill(oDataSet,"MyTable"); seem to take the longest to execute. Is there anything I can do to speed up this query? Or a different way to do this?
>
>
>
>string strAccessConn = "Provider=VFPOLEDB.1;Data " +
>"Source=P:\\Mydir\\;Mode=ReadWrite|Share Deny None;Extended " +
>"Properties=\"\";User ID=\"\";Password=\"\";Mask Password=False;Cache " +
>"Authentication=False;Encrypt Password=False;Collating Sequence=MACHINE;DSN=\"\"";
>
>string strAccessSelect = "SELECT * FROM MyTable WHERE MyField = '" + lcMyVar + "'";
>
>DataSet oDataSet = new DataSet();
>oDataSet.Tables.Add("MyTable");
>
>OleDbConnection oConn = new OleDbConnection(strAccessConn);
>OleDbCommand oAccessCommand = new OleDbCommand(strAccessSelect,oConn);
>OleDbDataAdapter oDataAdapter = new OleDbDataAdapter(oAccessCommand);
>
>oConn.Open();   //Slow here.
>oDataAdapter.Fill(oDataSet,"MyTable"); //Slow here.
>
>
>
>Thanks,
>
>Jerry
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform