What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 3832 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > "System.OutOfMemoryException"-How to Solve? ...
Ganeshsvelu

"System.OutOfMemoryException"-How to Solve?

Replies: 8 | Posted by: Ganeshsvelu on 4/8/2010 | Category: C# Forums | Views: 5014 | Status: [Member]  


I want to upload mdb file that file capacity is 26MB.I Upload that one successfully after i will store that datas in sql server 2008 table.I will use storing datas for String builder & String writer.It shows "System.OutOfMemoryException".


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Vuyiswamb
Vuyiswamb  
Posted on: 4/8/2010 7:40:06 AM
Level: NotApplicable | Status: [Member] [MVP] [Administrator]

Add this in the webconfig between the System.web

<httpRuntime maxRequestLength="500000"/>


Thank you for posting at Dotnetfunda
[Administrator]

Ganeshsvelu, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ganeshsvelu
Ganeshsvelu  
Posted on: 4/8/2010 9:30:29 AM
Level: Starter | Status: [Member]

Now its working fine but after i stored the values in sql server 2008 table.It takes more time to store then it shows this error

"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding".

Ganeshsvelu, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Vuyiswamb
Vuyiswamb  
Posted on: 4/8/2010 10:40:34 AM
Level: NotApplicable | Status: [Member] [MVP] [Administrator]

if you use ado.net set your command object timeout to 0 that means infinite , it will not timeout.

Thank you for posting at Dotnetfunda
[Administrator]

Ganeshsvelu, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ganeshsvelu
Ganeshsvelu  
Posted on: 4/9/2010 12:23:39 AM
Level: Starter | Status: [Member]

It shows this error.

Incorrect syntax near ')'.

Ganeshsvelu, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ganeshsvelu
Ganeshsvelu  
Posted on: 4/9/2010 12:29:12 AM
Level: Starter | Status: [Member]

I Use this command.

string strCon = _connectionString;//cms.Connection.ConnectionString;
SqlConnection objCon = new SqlConnection(strCon);
objCon.Open();
SqlCommand objCom = new SqlCommand(sqlText, objCon);
objCom.ExecuteNonQuery();
objCon.Close();

Ganeshsvelu, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Vuyiswamb
Vuyiswamb  
Posted on: 4/9/2010 2:43:40 AM
Level: NotApplicable | Status: [Member] [MVP] [Administrator]

Ganeshsvelu always put your code in code tags, look at the Forum guidelines. Another thing dont open the connection while you still initializing the objects. your code should look like this

string strCon = _connectionString;//cms.Connection.ConnectionString;

SqlConnection objCon = new SqlConnection(strCon);
SqlCommand objCom = new SqlCommand(sqlText, objCon);
objCom.CommandTimeout = 0;
try
{
objCon.Open();
objCom.ExecuteNonQuery();
}
catch(sqlException ex)
{

//print the ex.Message here
}
finally
{

objCon.Close();
}


look at the Bolded part its the timeout set to infinite

Thank you for posting at Dotnetfunda
[Administrator]

Ganeshsvelu, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2013 3:47:40 AM