Hi,
I have a datalist on my page to select data from a table
I want to access it with code to insert its values to another table. Te datalist will return more than one row, so i'd like the values seperated by commas when they are inserted to the new table (all in one row).
I have looked around and it seems that I need to do something to the select statement of the other control first - I have got:
SELECT [Usersname]= COALESCE (Usersname + ' , ' , ' ')
FROM [Transactions] WHERE ([Itemid] = @dotnet.itags.org.Itemid)
Does that look right?
And when I have selected these values, how do I insert them in the same format (separated by commas) ?:
DataView dv = SqlDataSource2.Select(DataSourceSelectArguments.Empty) as DataView;
string receivername = dv[0]["receivername"].ToString();
command.Parameters.AddWithValue("@dotnet.itags.org.recievername", receivername);
Would that still work?
Thanks,
Jon pls help!!
You can pass the value (comma separated value) to a stored procedure as a parameter.
Within the procedure you can insert the data into the table. Before inserting the data into the table we have to split it by comma and then we have to place in a temporary table.
Now we have to extract the data from temp table to actual table.
There is a function called "split" is available to split the data and it will return the data as a table. You can use the same function to insert into your table.
You can get this function at of this URL:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648
http://vadivel.blogspot.com/2006/05/split-function-in-sql-server-method-1.html
Hope this helps you.
0 comments:
Post a Comment