ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP 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 June 17th, 2003, 07:28 AM
cinners cinners is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Pennsylvania
Posts: 30 cinners User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Question Guid's

I have a checked listbox being populated from a database using a data reader.The form loades correctly now I want to cycle through the items checked and get the GUID assiciated for each location this will be passed to a stored procedure for insert/updating a database can anyone help I'm confussed ????

Dim commandSql2 As New SqlClient.SqlCommand()
commandSql2.Connection = conSqlOral
commandSql2.CommandText = "Select Location_Name,Location_Street,Location_City,Locati on_Guid from Location Where Location_Oral is NOT null Order by Location_Name"
Dim datReadOral As SqlClient.SqlDataReader
datReadOral = commandSql2.ExecuteReader
Dim HoldGuidOral As String
Dim strGuidOral As String
Do Until datReadOral.Read = False
chkOralLocations.Items.Add(datReadOral.GetValue(0) & " " & datReadOral.GetValue(1) & " " & datReadOral.GetValue(2))
strGuidOral = datReadOral.GetValue(3).ToString '& " " & datReadOral.GetValue(3).ToString
HoldGuidOral = HoldGuidOral & ", " & strGuidOral
'HOLDS THE NAME AND ORAL LOCATION GUIDS
Loop
conSqlOral.Close()
I = 0
For I = 0 To chkOralLocations.Items.Count - 1
If chkOralLocations.GetItemChecked(I) = True Then
HoldOralLocations = HoldOralLocations & " " & chkOralLocations.

All I get is the locations but no guid's ???

Reply With Quote
  #2  
Old June 17th, 2003, 10:54 AM
wes wes is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 24 wes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Your problem is, your list is only storing the locations, that is why you aren't getting the location's GUID. I see that you are storing the GUIDs, just not using them or even creating a link between them and the list box.

What you should do is, read the GUIDs into a comma separated string like you have, but after you get out of the read loop, SPLIT the string into an array. This way, if you have a location in the list at index 5, your array has the corresponding GUID also at index 5 (both the list and the array index will start at 0).

Code:
' ... code
Do Until datReadOral.Read = False 

    strLocationName = datReadOral("Location_Name")
    strLocationStreet = datReadOral("Location_Street")
    strLocationCity = datReadOral("Location_City")
    intLocationGUID = datReadOral("Location_Guid")

    strGUIDs = strGUIDs & intLocationGUID & ","

    chkOralLocations.Items.Add(strLocationName & " " & _
        strLocationStreet & " " & strLocationCity)

Loop 

conSqlOral.Close() 

If Len(strGUIDs) > 0 Then
    strGUIDs = Left(strGUIDs, Len(strGUIDs)-1)
End If

arrGUIDs = Split(strGUIDs, ",")

For I = 0 To chkOralLocations.Items.Count - 1 
    If chkOralLocations.GetItemChecked(I) = True Then
        intThisGUID = arrGUIDs(I)
        strSelectedGUIDs = strSelectedGUIDs & intThisGUID & ","
    End If
Next

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Guid's


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 6 hosted by Hostway
Stay green...Green IT