.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Strange for loop problem

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
Hi, I have this problem with moving a number of documents stored in a SharePoint Document Libray progamatically.The Document library is called "CR" which stores Change Management word documents.  Within this document library there may or may not be a folder which stores attachments (other documents, pictures etc) associated with the CR Document. When a button is pressed this code should see if the CR document has a corresponding folder, and then iterate through each file in that folder and move it to another archive folder.The code I have is as follows:SPList crlist = CR.Web.Lists["CR"]; for (int i = 0; i < crlist.Folders.Count; i++) { if (crlist.Folders[i].Folder.Name == "CR " + CR["CR Number"]) { for (int ii = 0; ii < crlist.Folders[i].Folder.Files.Count; ii++) { crlist.Folders[i].Folder.Files[ii].MoveTo(folderlist.RootFolder.ServerRelativeUrl + "/" + year.ToString() + "/" + WorkflowItem.Title + "/" + crlist.Folders[i].Folder.Files[ii].Name); } } }CR is list item (codument) which this code is working on at the time.crList is the sharepoint docu

View Complete Post

More Related Resource Links

Strange Photo upload problem


I'm working project it's live on shared hosting

we'er uploading photos to a file on the server everything works fine the photo is resized renamed and sent to the folder

the upload page returns the thumbnail and the full size photo it's there all the photos have to be approved by an admin

twice now after they have been approved they disapear I checked the folder they are not there could there be anywhere

on the server they could get hung up before they go into the folder I have it setup so when you delete the data base entry it deletes the photo from the folder othe than that you need to open the folder and delete the photo this has hapened twice now I tried to recreate it with no luck

thaks for your help in advance

Strange URL Routing Problem, participially working


I am setting up URL Routing on my existing project. I am not using mvc.

The routing only working like this: http://www.example.com/sdevil.m

not working with single word like this: http://www.example.com/sdevil

I am getting error message:The resource cannot be found.

Looks like when I using single word, application think that is folder?

How can i fix this? Thank you for any helps.

Wickedly Strange .Net WPF Performance Problem Dissapeers with Windows 7 Performance Monitor Open

Hello Everyone, I have been developing one large and complex WPF application for 13 months now, all is going well and especially tonight as I now have some sort of clue or hint to what I have been seing now for quite some time.  Here is the rundown. 1) Running on i5 processor with 4GB RAM and Windows 7 2) The application was developed all in .Net 4.0, WPF C#. 3) It is heavily GUI intensive and also uses Entity Framework Detached for Database Access. 4) Is multi-threaded / multi-tasking. I am a nutcase when it comes to testing.  Since my graphical application heavily depends upon performance and determinsm (please somebody don't start with the C++ vs .Net on here) and has been performing great FOR THE MOST PART.  Every once in a while, I see that the application runs into the weeds for 5 or 6 seconds and the interface is unresponsive.  I have this thing tuned finely too.  Well now toward the end of development I have finally had to face that bug so to speak.  I can force it by clicking spastically on my buttons causing an event storm and making the system update the GUI.  SO!  Great start, I can now cause the problem on a regular basis (for you youngsters that is actually a good thing)!  Alright, so I start with the easiest investigative tool, CNTRL - ALT - DEL into Windows 7 Performance Monitor.  As you can tell from

Strange Problem - SSIS Fails with "Syntax error, permission violation, or other nonspecific error".

Hello, I have a strange issue while I am deploying a package to one of the environment server. I have 2 XML Source, in the DataFlow, and one will extracted based on a value of variable that is passed from run time (package is executed from a Job) and other will be extracted all time. The next Step I have is a Execute SQL Task in ControlFlow wihich will execute after DataFlow. This has 2 input parameters and some SQL query that uses the param. Now this one fail on the target environment with below error: failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. I got the error when I did a SSIS Text File Log. Note: If I run the package in BIDS with the same XML files it work. Also when I deploy the package to my Dev Server it works. When I compare the Dev DB with the target environment DB - Both are same. The Service Acount has permission - as I can see the DataFlow task completed. Another Point: The XML Load Data Flow that executes based on the Variable Value does not execute on target environment, even if the value is passed as "True" (It is Boolean Type) But this variable is NOT an input for the Execute SQL task that fails. I am not sure w

Using loop problem in vb.net 1.1

Hi All, I am uploading large file via webservice using below my code in vb.net 1.1. Problem is vb.net 1.1 don't know Using Object loop. I would like to know any other loop similar Using loop to replace in vb.net 1.1  Using fs As New FileStream(FilePath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read)   fs.Seek(Offset, SeekOrigin.Begin)    fs.Write(buffer, 0, buffer.Length)End Using

WCF very strange problem

Hi,My issue ie a little bit comlicated, and I hope I'll find someone who will be able to deal with my complicated problem...I'll tryto describe it:1. I have a few wcfs that I located inside a website for having them "on air" on iis and ready to be called.    I have a website contains service references to those wcfs.2. Our web server is behind a load balancer, so we give another local name to each web service / website for a case     of calling them from inside the server. We declare the names changes in the "hosts" file. What I did is:1. upload the website with the wcfs. I also gave it a start simple page for being sure it is on the air:http://qonlineservices.qgroup4u.com/ you can see that the simple test page is writing moshi.2. Making services references in my website: www.QEnglishCenter.com to the appropriate WCFs thatlocated in: http://qonlineservices.qgroup4u.com/. I could easily create the service references because the wcfs therewere recognized immediately.3. I changed the urls to the wcfs inside the web.bconfig and the other files in the service reference: svcinfo, wsdl, disco... to bethe local url that we gave them.4. I changed the url in the web.config to the local url.5. I didn't changed the binding of the endpoints to webhttp or something like this.I hope

Loop through datatable always have problem


Hi I pull data from Database to be in a data table called dtDatatable after which specified that to the gridview.

 ElseIf Not dtTransaction Is Nothing Then

 gvTransaction.DataSource = dtTransaction


For i = 0 To gvTransaction.Rows.Count // I do a loop to loop through the table --> but it always displayed error saying there is no row position at row 2. 


i have used different ways to go around this. but still get the same error.Please assist.. 

Thank you!

Strange clipping problem

I am trying to design a control that resembles a door and it's swing. 
I have a few transforms to alter the swing. 
I am having a problem when the transform flips the rectangles and arcsegment out of the bounds of the UserControl. 
Even when I have the ClipToBounds property set to false on the UserControl and the MainWindow I still have problems.
The MainWindow will clip the UserControl even though the transform shows the UserControl. Please help.
UserControl x:Class="Test.SingleLeaf"
       xmlns:Test="clr-namespace:Test" mc:Ignorable="d" 
       x:Name="_singleLeafDoor" ClipToBounds="False"

MOSS 2007 Strange Problem with edit forms, content types and document library columns


I'm having a strange problem and have not been able to track down any useful answers over google.

I inherited a SharePoint site that I am now making some changes to.

I am having problems with one document library.  We had custom edit forms on this document library, which I was finding a pain to maintain so I reset them back to the site definition.  This edit form now shows only those fields that are associated with the Document content type (the only content type - I've deleted the others) on the document library.  There are other columns on this document library that are NOT associated with the content type that I would like to show on the edit form but they are not available when I try to add them to the content type via Settings > Document Content Type > Add from existing site or list columns.  The select columns from drop down is set to List Columns.  The Additional Authors column is just not there.

I CAN see this field on the all items view for the document library, it is there and populated with data.

Setting the Allow Managed content types radio button to NO does not have any impact on which fields are visible on the form- I still see those same fields that have been associated with the Document content type.

Has anyone else seen this or does anyone have any thoughts?? 

They will be muc

Strange Behaviour of For Loop


Hi Friends,

I am getting Strange behaviour from the for loop.

Here is the loop

for(i=1, i<=1000000, i++)


label1.text = string1;( string 1, 2 , 3 comming from logic)

label2.text = string2;

label3.text = string3; 

label4.text = string4;

once i got them i storing in the table of sql server using following steps,

SqlConnection conn = new SqlConnection();
                     conn.ConnectionString = " connectionstring ";
                     SqlCommand cmd = new SqlCommand();
                     cmd.CommandType = System.Data.CommandType.Text;
                     cmd.CommandText = "INSERT INTO table(value1, value2, value3, value4, value5) VALUES( @i, @value1,@value2,@value3,@value4)";
                     cmd.Parameters.Add(new SqlParameter("@i", i ))

GridView delete using stored procedure problem (strange)


I'm getting an error and I can't understand why is this happening...
I have an stored procedure which receives a parameter to delete the database row corresponding to that key-parameter. In the GridView_RowCommand I'm setting up the datasource in the e.CommandName == "Delete" option     

this.SqlDataSourceGridView.DeleteCommandType = SqlDataSourceCommandType.StoredProcedure;
this.SqlDataSourceGridView.DeleteCommand = "spDeleteGridView";

Then in the GridView_RowDeleting event, I'm preparing datasourceDeleteParameters with the Key that I want to delete in my database and call the         

this.SqlDataSourceGridView.Delete ( );

The row is deleted in the database but, and here is the problem, there is something that before it got error and throws me that:

El procedure or funcion 'spDeleteGridView' waits the parameter '@PARAM', that what not expected.

I must add the information that debugging GridView_RowDeleting it ends normally and calls the GridView_RowDeleted...

Any help??

Thank you!!!

Strange Access Denied Problem


I have SP2010 stup with a TFS portal. Brand new machine for the job. Installed 2008R2, Installed SP2010 when release, Installed TFS when released. Set the relative TFS groups up to people could see work items and so fourth in the portal. Added the relative users to the relative SP groups and it all works fine Except everyone bar me gets Access denied if they have been logged out of portal for too long. The way this is fixed is by me logging in.

I'll try to be clearer.

User A tried to log into the portal first thing in the morning.
User A gets Access Denied.
User A SMSs Me (the admin)
I log in and do nothing but login, don't touch a single link, don't do anything, Just login.
User A can now Login in.

User A can be any none admin type user. It happens to everyone.

This has been going on since the day it was setup. Basicly the day after VS2010 was released. It has not been a majour issue so far as we are only doing prep work for a new project so only a couple of people have been adding documents but thats about to change so I need to sort it out.

Any Ideas.



Very strange Linked Server problem



I've got a server setup with SQL2008R2. It connects (linked server) to another SQL server which runs SQL2005. The link works fine in management studio, and it also works ok in code (where I use it to query the data). But after a few minutes of inactivity, suddenly the link begins to fail in code (SQLException; System.Data.SqlClient.SqlException: SQL Server Network Interfaces: Error getting enabled protocols list from registry [xFFFFFFFF]. ). I then open up management studio, click "Test connection"; management studio says it's ok. Running the code again, and it suddenly works fine for a few minutes, untill the same problem appears.

Seems like a bug, but is there a solution for this problem?

MCTS in Web Application Development in .NET 2.0

Sys.Application.addHistoryPoint Strange problem using prototype


Hello.I have inserted in a page

try {
Object.prototype.selectSingleNode = function (sXPath) {
var oEvaluator = new XPathEvaluator();
var oResult = oEvaluator.evaluate(sXPath, this, null,
if (oResult != null) {
return oResult.singleNodeValue;
} else {
return null;
} catch (er) {

The problem is that when i use Sys.Application.addHistoryPoint then my url becomes:
foo.aspx?sid=xxx&#v=227&selectSingleNode=function..... It contains the whole function...
Any ideas please?

Strange Problem with IBMDA400 OLE DB Provider


Dear All,

My objective to use SSIS to to pull data from DB2 and store into SQL Server.

Working environment is:
Database: DB2 UDB iSeries V5R3
Provider: IBM DB2 UDB for iSeries IBMDA400 OLE DB Provider
SQL Server 2005 SP: Latest i-e SP2

In connection manager, i have changed the following properties in OLEDB driver settings and connection with DB2 is tested successfully.
1- CATALOG LIBRARY LIST = AS/400 library
3- INITIAL CATALOG = Database Name
4- Defualt Collection = AS/400 library

After testing connection, I Created an OLE DB source and in OLE DB Datasource Editor set following properties:

In OLEDB source editor, if i use "Table or View" name option then the drop table list is populated perfectly and i can specify any table. With this option Package executes fine. But if i use the SQLCommand and specify the query, it prase the query correctly and i can preview the data in this source editor. But upon execution package return the following error message.

[OLE DB Source [1]] Error: An OLE DB error has occurred. Error code: 0x8

Strange problem in VS2008


I have been getting this problem with my forms in VS2008. Certain elements are missing when viewed in design mode though the codes are still in the source view. How do I fix this? Thanks

Below is the "design" view



And this is the "run-time" view.

Strange problem



I have problem in MS SQL 2008 R2 Enterprise version.

I am trying to use Data Flow Task (in DTS) to write in prediction querry results into the table. My input table has about 4000000 rows. When I try to execute task I obtain different result at each time. Once the output table has about 2000000 rows and once 3000000 (at each time DTS component turn to green color - complete with succes). Always the output table has less rows than the input table.


I have checked the querry (dmx) in visual studio and managment studio (with displaying the results on the screen) - at each time it works fine, number of displayed rows is the same as the number of rows in the input table (in the prediction join).


I have done it before in MS SQL 2005 Enterprice version and I did not observe any problems


What could be the problem?

Best regards,


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend