Rich
|
| Posted: 06/16/2004, 5:05 AM |
|
I have a form with two fields.
field1 is project_id - this is prepoluated from another form
field2 is project - this is a multiple list box.
I want to be able to select more than one project (using ctrl key for example), and have them be inserted into my table.
Currently, it will only add ONE row.
How do i enter more than one? What kind of event do i use and can someone help me form the code?
Thanks!
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 06/16/2004, 11:19 AM |
|
Is this similar to what you need: http://examples.codecharge.com/ExamplePack/ManyToManyLi...ManyListbox.php ?
This example is in CCS Example Pack and the required events are there.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Rich
|
| Posted: 06/16/2004, 11:35 AM |
|
Yes - that's it - however it discusses to put "custom code" into Before Show, After Insert, After Update and Before Delete.
I guess i'm not quite sure what kind of sql to put where? and how to create the syntax correctly
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 06/16/2004, 12:36 PM |
|
Rich,
This example is one of the more complex ones, although not too bad if you take it in steps. I don't know your table structure and don't know enough other details, but I would recommend that you first start only with using the Before Show event only to display the multiple selected values in the listbox (which you can update manually in the database for now). This way you can test just one SQL statement in one event. Once you get this working it should be easier to add the other events.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Rich
|
| Posted: 06/17/2004, 12:46 PM |
|
Ok - i have made some steps here. However, right now it's only inserting one row. I took the example and made the following changes as I was told i needed to use an array:
If Actions = "Update" Then
for i=lbound(CodeList) to ubound(CodeList)
CodeId = CodeList(i)
ConnectMonkey.Execute("INSERT INTO deployment_history (trackingid, Codeid) VALUES (" &CurrTrackingID&"," &CodeID&")")
next
This only adds one row. Any guesses?
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 06/17/2004, 2:17 PM |
|
Hmm, I didn't see such code in the example. I recommend taking the exact code from the example since it works OK.
EmpList = Split(Request.Form("employee_list"),",")
If Actions = "Update" Then
'Insert assigned employees
For Each EmpID In EmpList
EmpProjectConn.Execute("INSERT INTO projects_employees (project_id, emp_id) VALUES (" & EmpProjectConn.ToSQL(CurrProjectID,ccsInteger) & "," & EmpProjectConn.ToSQL(EmpID,ccsInteger) & ")")
Next
End If
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Rich
|
| Posted: 06/18/2004, 5:52 AM |
|
Ok, i have used that code - obviously i had to modify it for my own database,etc . HOwever when i publish it, there's a message saying that only the first record selected will be inserted.
I have verified that i checked the "multple" check box in the properties of the listbox. Very frustrating!
Any other thoughts?
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 06/18/2004, 10:39 AM |
|
That message means that CCS cannot use the standard database control to update your database. You would need to change the "Control Source Type" property to "Expression".
You can also contact our product support at http://support.codecharge.com if you need further help.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Eric B
|
| Posted: 07/06/2004, 6:48 AM |
|
This is exactly what I am looking for. Is there any way to get this:
http://examples.codecharge.com/ExamplePack/ManyToManyLi...hp?project_id=6
as ASP/VBScript source code? Thanks!!
Eric B
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 07/06/2004, 11:16 AM |
|
Sure. All those examples are included with CodeCharge Studio. Here are the instructions on how to create a new project with these examples: http://docs.codecharge.com/studio/html/ProgrammingTechn...xamplePack.html
The appropriate ASP code will be generated if you select "ASP" when creating this example/project.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |