Click here to Skip to main content
15,921,959 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have 3 arrays
C#
objc.UserName = UserName;
objc.UserPhone = Userphone;
objc.UserMail = UserMail;

// here username,userphone,usermail are array 

for (int i = 0; i .UserName.Length; i++ )
{
    for ( int j = 0; j < UserPhone.Length; j++ )
}

}

how to take values one by one and send to database
first time username1,userphone1,usermail1 value will insert then come back and take username2,userphone2,usermail2 value unless that finish .
Posted
v3

Try:
C#
int minlength = Math.Min(UserName.Length, Math.Min(UserPhone.Length, UserMail.Length));
for (int index = 0; index < minLength; index++)
   {
   // Send UserName[index], UserPhone[index], UserMail[index] to your chosen DB.
   ...
   }
We can't tell you how to send it to your DB, we have no idea what DB you are using. You should have that code anyway...
 
Share this answer
 
Comments
Member 11970398 26-Nov-15 6:37am    
i am using sql server database
Member 11970398 2-Dec-15 2:18am    
if i have one more parameter like validdate then how will i add
Member 11970398 2-Dec-15 2:33am    
done done
Redesign, you should hold single array of objects User that has properties Name, Phone, Mail. Then you loop through that array and use objects properties.

If you're stuck with three array then this is the solution:
NOTE THAT I DO NOT RECOMMEND THIS, read the above redesign suggestion

C#
int arrayLength = UserName.Length
for (i = 0; i < arrayLength; i++) {
    //send to database UserName[i], UserPhone[i] and UserMail[i]
    // DONE
    // NOTE that having variables with capital letter is against Microsoft recommendation for variable naming which should be camelCase and not PascalCase
}
 
Share this answer
 
v2

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