TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
mahesh kumar B M
NA
44
1.1m
Generic method To add sql parameters dynamically for executing sql parameterized query for ado.net
Aug 30 2012 3:31 AM
How to add sql parameters dynamically for executing sql parameterized query:
let us say i have a querytext :" select a,b,c from table1 where
y=@yvalue
and
i need to pass this query and the params to one of the db function method and there i have to fetch the data by executing this parameterized query.
at the method call : dbfun.fetchdata(connection ,querytext,params(note:have to send the parameters and values here i.e @xvalue and its value like that here))
at the dbfun class write one method called fetchdata to call the query using parameterized query format.I just wanted to know,how we add those params and values in this method dynamically for adding like
command.parameter.add("@xvalue",its value);
parameter.type=sqldbtype.its data type
parameter.value=some value...
Im interested in knowing the
method of adding these params and its values and dbtype dynamically at runtime depending on the param list ..please help on this.
please note
that it should be a generic query,so that if you add some extra parameters later to this query,this method should be able to add those params and fetch the data effectively
.
Reply
Answers (
5
)
WMI Question: How to get Display properties of Multiple Monitors Attached to my Computer
File Upload in edit Gridview