c# - Regular Expression for word starting with Colon (:) -
i new regular expression, please me in regards. have sql query below
declare @name varchar(20) declare @branchcode char(3) select @name=:entername select @branchcode=:enterbranchcode select * master name=@name , branchcode=@branchcode
now need replace :entername , :branchcode actual value. trying solve using regular expression.
is regex ok (/\b:\s+/g") ???
all want achieve
no, sqlparameters for. in addition creating variables can used within sql, protect against sql injection attacks, you're opening for.
plenty of examples on stack overflow how use them, such this one.
in order parse these out given query prompt user values...
- simply take query regular parameters,
select * foo bar = @barname
- you can regex
@barname
parameters pretty easy regex@\w+
- for each parameter, ask user
- the type of parameter
- the value of parameter
- construct sqlparameter each , add sqlcommand object.
you might able away without 3.1. or might able make best guess based on give you. must ask them explicit.
Comments
Post a Comment