A little SQL problem

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/69838?pagenum=1
05 November 2025, 01:31

Topic


thermal_seeker
A little SQL problem
19 February 2011, 09:07


MS SQL 2005 DB
I have created a form that is partially filled by bringing in data from another table.
The Username dropdown decides which table the data should go into and the other dropdown boxes are the columns in that table. Obviously I cant have the columns named because when the username dropdown is changed the other dropdowns are re-populated with different data.
Is it possible to have the columns linked to the results of the dropdowm boxes??
Code:

 PiggieWeightsDataSource.InsertCommand = String.Format("INSERT INTO {0} (freddie, bertie, gertie) VALUES(@freddie, @bertie, @gertie)", UNDropDown.SelectedItem.Text)


PiggieWeightsDataSource.InsertParameters.Add("freddie", P0TB.Text)
PiggieWeightsDataSource.InsertParameters.Add("bertie", P1TB.Text)
PiggieWeightsDataSource.InsertParameters.Add("gertie", P2TB.Text)


ie. "freddie" is the result of the selected text from dropdown box 2

bertie is the result of dropdown box 3

etc

Dave

 

Replies ...


ruirib
19 February 2011, 10:32


I guess you would need to create the SQL dinamically, considering the chosen values in the dropdowns.
thermal_seeker
20 February 2011, 04:39


Thanks Rui
That pointed me in the right direction smile
ruirib
20 February 2011, 05:56


Great smile.
© 2000-2021 Snitz™ Communications