Solved

array syntax help please

Posted on 2004-10-19
2
201 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 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