In summary, integrating B ds gives BL where L is the length of the solenoid due to Ampere's law. However, the usual assumption of an infinitely long solenoid does not directly give the length. Instead, the equation is combined in terms of n, the turns per length. When using this equation for a real solenoid, the total turns and total length of the solenoid can be plugged in as N and L, respectively. However, these values are different from the N and L used in Ampere's law.
The usual method of using Ampere's law does not directly give the length of the solenoid, because the usual assumption is that the solenoid is infinitely long.
The Amperian loop is usually a rectangle, with a side of length L inside and outside the solenoid, and there are N turns of the solenoid passing through the loop. Then Ampere's law gives:
[tex]
B L = \mu_0 N I
[/tex]
But the specific values of N and L were rather arbitrary in that they depended on how big the loop is; if the loop's side inside the solenoid were doubled, both N and L would double. To get something useful, they combine this in terms of n, the turns per length:
[tex]
B = \mu_0 n I
[/tex]
Now when you use this equation for a real solenoid, if they give you the total turns and total length of the solenoid, you can go back and plug these in:
[tex]
B = \mu_0 \frac{N}{L} I
[/tex]
but these values of N and L (total turns and total length) are technically not the N and L (turns going through Amperian loop and length of one of the sides of the Amperian loop) that you use in Ampere's law.