|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Looping through a listbox and calling a SP
I am connecting to a MSSQL 7 database in VB6
I have two text boxes, the user types in the Order Number in text1.text and their email alias in text2.text, they click the command1 button and this verifies the order is open against a view, if the order is open it adds the order number & text2.text to a listbox. No problem here. Now, command2 button runs this: Private Sub Command2_Click() Dim intCounter As Integer If List1.ListIndex = -1 Then Exit Sub For intCounter = List1.ListCount - 1 To 0 Step -1 Ord_No = Left(List1.List(intCounter), 7) Email = Trim(Mid(List1.List(intCounter), 8)) Set Conn = New ADODB.Connection Conn.ConnectionString = cnStr Conn.Open Set Cmd = New ADODB.Command Set Param = New ADODB.Parameter Param.Name = "OrderNo" Param.Type = adVarChar Param.Size = 10 Param.Direction = adParamInput Param.Value = Ord_No Cmd.Parameters.Append Param Set Param = New ADODB.Parameter Param.Name = "Email" Param.Type = adVarChar Param.Size = 50 Param.Direction = adParamInput Param.Value = Email Cmd.Parameters.Append Param Cmd.ActiveConnection = Conn Cmd.CommandText = "fns_unresolved_ticket_email" <---Stored procedure that calls xp_sendmail Cmd.CommandType = adCmdStoredProc Cmd.Execute Set Cmd = Nothing Set Conn = Nothing Next intCounter End Sub This works correctly except it emails the last Order Number in the listbox for each loop through the listbox, instead of emailing each order number. Now I have been given VB .NET by my employer, will this make it easier, or will I have the same difficulties? I hope this makes sense, I appreciate the help. Doug |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Looping through a listbox and calling a SP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|