Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My connection string -------

XML
<appSettings>
        <add key="Connstr" value="Server=192.168.1.6\SQLExpress;database=Mydatabase;uid=usename;pwd=password;"/>
    </appSettings>


//Showing timeout error,how can i avoid it and set to infinite.

2nd question:-

string sqlquery = "Select * from tablename";
           SqlDataAdapter DA = new SqlDataAdapter(sqlquery, Connstr);
           DataSet DS = new DataSet();
           DA.Fill(DS);

//showing error-
Exception of type 'System.OutOfMemoryException' was thrown.

//In my database there are 5811753 rows.so tell me how can i access rows in dataset,by avoiding above error.
Posted

XML
<appSettings>
        <add key="Connstr" value="Server=192.168.1.6\SQLExpress;database=Mydatabase;timeout=100000;uid=usename;pwd=password;"/>
    </appSettings>

Happy coding!
:)
 
Share this answer
 
Hi,

see the below link it might be help you to solve your problem. The error occurs due to fetch so much data at a time. Better to fetch records in some interval. you can use paging. Might be it will solve your problem.

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/60432190-8b83-4f9e-a21f-4c830a5005fc[^]
http://msdn.microsoft.com/en-us/library/tx1c9c2f%28v=vs.80%29.aspx[^]
http://www.dotnetspider.com/forum/234222-System.OutOfMemoryException-thrown-case-huge-data.aspx[^]

Thanks,
Viprat
 
Share this answer
 
XML
Basically such scenario generate due to high execution sql query cost.
You can set appropriate timeout in connection string as below :

<appSettings>
        <add key="Connstr" value="Server=192.168.1.6\SQLExpress;database=Mydatabase;timeout=100000;uid=usename;pwd=password;"/>
    </appSettings>

and use below  preventive/precautionary steps for minize table scan :
1)Define appropriate index on database table.
2)Check query execution cose using explain plan.
3)Try to avoid such full table scan query.

Thanks & Regadrs
Prashant K.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900