The way I understand your problem it is something like "determine the probability that the gambler will reach N before she/he goes bankrupt".
This problem could then be represented by a Markov Chain with N+1 states (from 0 betting units to N betting units). Once you reach states 0 or N you have probability=1 of remaining there. For other states you have p probability of going up, q probability of going down and 0 probability of going to any other state or remaining there.
This translates to a transition matrix with 0's on the main diagonal except for 0,0 and N,N which are 1's. The diagonal above the main one will be composed of p's (except the 0,1 which is 0) and the diagonal below will be composed of q's (except the N,N-1 which is 0).
Now all we have to do is multiply a transposed vector (the "initial-state vector") by this matrix. It will be a transposed vector running from position 0 to position N with all components equal to 0 except the ith one, which is equal to 1. If we multiply the resulting vector an infinite number of times by the matrix, the Nth component of the resulting vector will have the probability that our gambler wins.
That is my guess. Now you tell me how to find that limit (and prove that it exists) and your question will be answered.