|
Hi,
I am developing a C# windows application(.net 2003).
The functionality of this application is to import all the records from a csv file to a table in a SQL Server 2000.
For this i am opening a sql connection and I am using Sql command. Here i set sqlcommand timeout to 500.
I am using a for loop to insert each record into sql table. After finishing all records i am closing and disposing sql connection.
This is working fine.
For some tables it is necessary to get primary key from another table and insert that primary key along with the current table's data.
For extracting that primary key i wrote funtion. This function opens a new sql connection and sql command having timeout 500.
After fetching data i am disposing that sql connection.
This funtion is called for each record in the csv file.
After inserting approximately 200 records it is giving an Exception Message
"Timeout Expired. The timeout period elapsed prior to obtaining a connection form the pool. This may have occured because all pooled connections were in use and max pool size was reached".
How to overcome this problem. It's urgent
Any one please help me.
Thanks in Advance.
Ramu
|
|
|
|
|
Ramu.M wrote: For some tables it is necessary to get primary key from another table and insert that primary key along with the current table's data.
For extracting that primary key i wrote funtion. This function opens a new sql connection and sql command having timeout 500.
Are you using stored procedures ? If yes then you can get this primary value through an output variable. This will avoid creating connection again.
Ramu.M wrote: After inserting approximately 200 records it is giving an Exception Message
Verify your code to find how many instances of SQLConnection will be open when it reaches 200 ? Try to reduce the number of connection objects open. Make sure that all SQLConnection instances are returned back to pool.
How you are disposing the objects ?
SqlConObject.Open()
SqlConObject.Close()
SqlConObject.Dispose()
Above code will keep the connection in opened state when any error happens on do operations. So it's better to wrap the connection in between using statements. This will dispose object even though any error happens.
using (SqlConObject)
{
SqlConObject.Close()
}
|
|
|
|
|
|
Hy,
Have you tried creating a buffer or such? I mean to create a list with your queries first. When you insert a new query to the list you call the function to get the UID and then fetch the data from the CSV file and then create the query. After you have finished creating the query list just open a connection to the server and loop inside the list to insert the data.
Hope it helps
Do your best to be the best
|
|
|
|
|
|
Hi,
How to remove/delete any particular file from any particular folder/directory?
Thank you in advance
(Riaz)
|
|
|
|
|
System.IO.File.Delete(strFileName)
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
|
Hi,
I have created one form containing some controls like buttons, textbox, labels and all, and i want to write the Event Handler for some controls in a different class file.I am using C# windows application. How to do that???
Rakesh B.P.
|
|
|
|
|
By default event handler will be added in the same class file. So if you need to write event handler method in your other class, modify event handler reference in InitializeComponent() method to your new class.
EventHandlerClass EventHandler = new EventHandlerClass ();
this.button1.Click += new System.EventHandler(EventHandler.button1_Click);
Why you want to split your event handler code to other class ?
If you are using .NET 2005, then you can make use of partial classes. Class name will be same, but you can keep the events in separate file.
Other way is using delegates.
|
|
|
|
|
Hi,
I have a big class with plenty of methods. But some of the methods inside this is not using now. So all these methods has to be removed which have no refernce. Is there any way to know which are the methods that is not having reference ?
|
|
|
|
|
You can right click on the method and choose 'find all references' ( from memory ) it finds all the places that call a function. Or you can just search the solution for the function name. Dong it for all in one go, not that I know of.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: You can right click on the method and choose 'find all references' ( from memory ) it finds all the places that call a function.
Thanks Christian. This what I am doing now. But it takes lot of time. And I have got lot of function to go. So I thought any way to list all the unreferenced functions. Do you know about Redgate profiler ? will that help on this issue ?
|
|
|
|
|
How do you close a C# application with more than one form? I can close the forms but the application keeps running in the task manager's processes. Can anyone help me out ?
Girish Soni
|
|
|
|
|
sonigirish wrote: I can close the forms but the application keeps running in the task manager's processes. Can anyone help me out?
You have to close the main form(where main() function resides). Once you close the main form, it will be removed from process list.
|
|
|
|
|
Thanks for reply I am having two forms when i click button on form1 then form1 will close and form2 will open. I want to close application by clicking on button on form2.
Girish Soni
|
|
|
|
|
sonigirish wrote: i click button on form1 then form1 will close and form2 will open. I want to close application by clicking on button on form2.
In which form your main() method resides ? How you are closing form1 when form2 is open ? Are you just hiding form1 when form2 shows ?
|
|
|
|
|
My main method is in program.cs and my first form is form1 and on button click event code is
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Form2 frm = new Form2() ;
frm.Show() ;
}
I want to close application on form2' button click ie button2-Click event
Girish Soni
|
|
|
|
|
sonigirish wrote: I want to close application on form2' button click ie button2-Click event
Write a method in your first form which closes that form. Using delegates, call this method when form2 is closed. This will close your entire APP.
Alternatively, you can pass form1 object to form2 constructor, and dispose this object when form2 closed.
|
|
|
|
|
hi
u can use Application.Exit() where evr u plan to terminate the application. for eg. if after showing form1 u want to close it, then on lets say btnExit_click event, u can use Application.Exit() to close the entire application and this would also remove the application thread from the task manager. This method basically terminates the application domain which the application is running in.Hope this would help.
Cheers
|
|
|
|
|
If your app is running with all forms closed, you must have a thread running. What if you debug, close all and hit the break menu item to see where the code is ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Use Application.End() function it will close the application
with regards
yogesh agarwal
|
|
|
|
|
You mean Application.Exit() ?
|
|
|
|
|
hi all and thanks for trying to help ,
currently im working on a project wich involves a multi threaded server
and a client program .
can anyone advice me of a common method which i could retreive with my client program an updated list of users online on my server , which keep updating once user left the server or a new user has joined the server ,
i mean many online games or applications have something like that , i would like to know how to do it , any advice would be great thanks.
Net
|
|
|
|
|
When any user update in a server list then server send an event to client with updated list and then update the client list.
Clien hold the Remote server object and when server object raise an event then client trace that event.
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|