[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Read a value from dataset

Posted on 2004-11-25
5
Medium Priority
?
526 Views
Last Modified: 2012-06-21
Hello I am trying to read a value from dataset check it file image exists based on value if not then use default image.
I am getting an error message of
BC30311: Value of type 'System.Data.DataRowCollection' cannot be converted to 'String'.
is there another way to get the value from the dataset?

 MyCommand.Fill(DS, "mytable")
      Dim FilePath As String
      Dim i as integer
      for i=0 to DS.Tables("mytable").Rows.Count-1
'***Error stops here**      FilePath =Server.MapPath(DS.Tables("mytable").Rows[i]["picture"]))
    If File.Exists(FilePath)  Then
      
    'picture available
    Else
       DS.Tables("mytable").Rows[i]["picture"]= "images/none.jpg"
         end if
      Next
0
Comment
Question by:fbetag
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:hismightiness
ID: 12683211
Have you tried this:

MyCommand.Fill(DS, "mytable")
     Dim FilePath As String
     Dim i as integer
     for i=0 to DS.Tables("mytable").Rows.Count-1
     FilePath =Server.MapPath(CType(DS.Tables("mytable").Rows[i]["picture"]), String))
    If File.Exists(FilePath)  Then
     
    'picture available
    Else
       DS.Tables("mytable").Rows[i]["picture"]= "images/none.jpg"
        end if
     Next
0
 
LVL 3

Accepted Solution

by:
gbelken99 earned 1200 total points
ID: 12707516
Try this

ds.Tables("mytable").Rows(i).Item("picture")
0
 
LVL 1

Author Comment

by:fbetag
ID: 12710443
hismightiness I still get this error with your sugguestion.
BC30196: Comma expected


gbelken99
Ah thanks your sugguestion works great it was just a matter of formatting Thanks you made my week....
0
 
LVL 9

Expert Comment

by:hismightiness
ID: 12710843
Had I known you were getting an error, I would have ammended my example.  Thanks.
0
 
LVL 3

Expert Comment

by:gbelken99
ID: 12710906
.NET Can really be picky with Syntax but once you get past the learning curve its far and beyond classic ASP Thanks for the points
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month19 days, 9 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question