Last post Jul 07, 2017 08:38 PM by limno
Jul 07, 2017 02:04 PM|Kvetch|LINK
I know in sqlquery its
INSERT INTO MyTable ( Column1, Column2 ) VALUES ( Value1, Value2 ), ( Value1, Value2 )
If the user enters a string of values separated by either a space or comma, how would I modify each word in the string so that
a, b, c
becomes (VALUE1, a), (VALUE1, b), (VALUE1, c)?
Value1 is a constant that's selected by the user.
And then how would I insert these multiple rows into my database?
Thanks in advance
Jul 07, 2017 02:58 PM|oned_gk|LINK
split then loop it to insert one by one
foreach(string s in TextBox1.Text.Split(','))
//insert into table1 (col1) values (s)
Jul 07, 2017 08:38 PM|limno|LINK
The other option on database side is to use a UDF split or TVP in your database to insert your input in one run.