Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a function that takes the table name and the array values as input(for dynamic invocation of the query).How to insert the individual array values to the respective fields in the database (with parameters) if possible with LINQ also?
Posted
Comments
Azee 29-Sep-13 3:53am    
What have you tried? a little demonstration might get you a help quick.
Sampath Lokuge 29-Sep-13 3:54am    
Can you post your function ?

1 solution

If i understand your problem you have created a function which get a input parameter with array type that pass query structure to function and function dynamically create an statement,
for calling a table for select or insert statement you should call it by dynamic query, you can call it in your function for example:

SQL
Alter procedure func (@tableName nvarchar(100))
as
begin
declare @cmd nvarchar(max) =
N'select * from '+ @tableName
print 1
exec (@cmd)

end

exec func N'Task'


but consider if your database name is also dynamic as your connection string is only with one database!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900