Solved

array syntax help please

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now