vb.net - Statement is not valid in a namespace -
the code below returned statement not valid in namespace using vs-2010. please review code , recommend reasonable fix, research indicates should have bases covered importing presiding namespaces.
what more should to make valid?
the rest of these comments here past mandate verbose.
imports system imports system.web imports system.web.security ' membershipprovider.createuser public overrides function createuser(byval username string, _ byval password string, _ byval email string, _ byval passwordquestion string, _ byval passwordanswer string, _ byval isapproved boolean, _ byval provideruserkey object, _ byref status membershipcreatestatus) membershipuser return me.createuser(username, password, email, _ passwordquestion, passwordanswer, _ isapproved, provideruserkey, false, "", status) end function ' ' odbcmembershipprovider.createuser -- returns odbcmembershipuser ' public overloads function createuser(byval username string, _ byval password string, _ byval email string, _ byval passwordquestion string, _ byval passwordanswer string, _ byval isapproved boolean, _ byval provideruserkey object, _ byval issubscriber boolean, _ byval customerid string, _ byref status membershipcreatestatus) _ odbcmembershipuser dim args validatepasswordeventargs = _ new validatepasswordeventargs(username, password, true) onvalidatingpassword(args) if args.cancel status = membershipcreatestatus.invalidpassword return nothing end if if requiresuniqueemail andalso getusernamebyemail(email) <> "" status = membershipcreatestatus.duplicateemail return nothing end if dim u membershipuser = getuser(username, false) if u nothing dim createdate datetime = datetime.now if provideruserkey nothing provideruserkey = guid.newguid() else if not typeof provideruserkey guid status = membershipcreatestatus.invalidprovideruserkey return nothing end if end if dim conn odbcconnection = new odbcconnection(connectionstring) dim cmd odbccommand = new odbccommand("insert users " & _ " (pkid, username, password, email, passwordquestion, " & _ " passwordanswer, isapproved," & _ " comment, creationdate, lastpasswordchangeddate, lastactivitydate," & _ " applicationname, islockedout, lastlockedoutdate," & _ " failedpasswordattemptcount, failedpasswordattemptwindowstart, " & _ " failedpasswordanswerattemptcount, failedpasswordanswerattemptwindowstart, " & _ " issubscriber, customerid)" & _ " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", conn) cmd.parameters.add("@pkid", odbctype.uniqueidentifier).value = provideruserkey cmd.parameters.add("@username", odbctype.varchar, 255).value = username cmd.parameters.add("@password", odbctype.varchar, 255).value = encodepassword(password) cmd.parameters.add("@email", odbctype.varchar, 128).value = email cmd.parameters.add("@passwordquestion", odbctype.varchar, 255).value = passwordquestion cmd.parameters.add("@passwordanswer", odbctype.varchar, 255).value = encodepassword(passwordanswer) cmd.parameters.add("@isapproved", odbctype.bit).value = isapproved cmd.parameters.add("@comment", odbctype.varchar, 255).value = "" cmd.parameters.add("@creationdate", odbctype.datetime).value = createdate cmd.parameters.add("@lastpasswordchangeddate", odbctype.datetime).value = createdate cmd.parameters.add("@lastactivitydate", odbctype.datetime).value = createdate cmd.parameters.add("@applicationname", odbctype.varchar, 255).value = papplicationname cmd.parameters.add("@islockedout", odbctype.bit).value = false cmd.parameters.add("@lastlockedoutdate", odbctype.datetime).value = createdate cmd.parameters.add("@failedpasswordattemptcount", odbctype.int).value = 0 cmd.parameters.add("@failedpasswordattemptwindowstart", odbctype.datetime).value = createdate cmd.parameters.add("@failedpasswordanswerattemptcount", odbctype.int).value = 0 cmd.parameters.add("@failedpasswordanswerattemptwindowstart", odbctype.datetime).value = createdate cmd.parameters.add("@issubscriber", odbctype.bit).value = issubscriber cmd.parameters.add("@customerid", odbctype.varchar, 128).value = customerid try conn.open() dim recadded integer = cmd.executenonquery() if recadded > 0 status = membershipcreatestatus.success else status = membershipcreatestatus.userrejected end if catch e odbcexception if writeexceptionstoeventlog writetoeventlog(e, "createuser") end if status = membershipcreatestatus.providererror conn.close() end try return getuser(username, false) else status = membershipcreatestatus.duplicateusername end if return nothing end function
your functions need wrapped in class or module.
imports system class myfunctions dim myvariable function myfunction() end function end class
from statement not valid in namespace on msdn,
the statement cannot appear @ level of namespace. declarations allowed @ namespace level module, interface, class, delegate, enumeration, , structure declarations.
to correct error:
move statement location within module, class, interface, structure, enumeration, or delegate definition.
Comments
Post a Comment