A little SQL problem - Posted (887 Views)
Junior Member
thermal_seeker
Posts: 430
430
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

No good at coding, but I can plough a field !!
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Snitz Forums Admin
ruirib
Posts: 26364
26364
I guess you would need to create the SQL dinamically, considering the chosen values in the dropdowns.
Posted
Junior Member
thermal_seeker
Posts: 430
430
Thanks Rui
That pointed me in the right direction smile
No good at coding, but I can plough a field !!
Posted
Snitz Forums Admin
ruirib
Posts: 26364
26364
 
You Must enter a message