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, 08: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: 7
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, 11: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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek