Solved

array syntax help please

Posted on 2004-10-19
2
202 Views
Last Modified: 2008-03-03
Hi There,

I am trying convert a function that I was using in asp to asp .net, I keep getting the error "overload resolution failed because no accessable 'create instance' can be called without a narrowing conversion". What have I missed?

Sean

    Public Shared Function killChars(ByVal strWords As String)

        Dim newChars As String
        Dim i As Integer

        Dim badChars As Array = Array.CreateInstance(GetType(String), "select", "drop", ";", "--", "insert", "delete", "xp_", "execute")
        newChars = strWords

        For i = badChars.GetLowerBound(0) To badChars.GetUpperBound(0)
            newChars = Replace(newChars, badChars(i), "")
        Next

        killChars = newChars

    End Function
0
Comment
Question by:bullrout
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 500 total points
ID: 12346476
Hi bullrout,

as i see from the definition of the CreateInstance in MSDN you can not do that for string objects
have you tried this

Dim badChars() as String = { "select", "drop", ";", "--", "insert", "delete", "xp_", "execute" }

Regards!
B..M
0
 
LVL 5

Author Comment

by:bullrout
ID: 12356175
Works like a treat thanks BM.

Sean
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question