.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 15th, 2005, 03:57 PM
dscheck dscheck is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 1 dscheck User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 55 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Looping through a listbox and calling a SP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway