Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 801779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:29:43+00:00 2026-05-14T23:29:43+00:00

I can’t figure it out for the life of me.. I’m using SQL DataSet

  • 0

I can’t figure it out for the life of me.. I’m using SQL DataSet Query to iterate to a Class Object which acts as a Data Model for Flex… Initially I used VB.net but now need to convert to C#.. This conversion is done except for the last section where I create a DataRow arow and then try to add the DataSet Values to the Class (Results Class)… I get an error message..

‘VTResults.Results.Ticker’ is inaccessible due to its protection level
(this is down at the bottom)

 using System;
 using System.Web;
 using System.Collections;
 using System.Web.Services;
 using System.Web.Services.Protocols;
 using System.Data;
 using System.Data.SqlClient;
 using System.Configuration;
 /// <summary>
 /// Summary description for VTResults
 /// </summary>
 [WebService(Namespace = "http://velocitytrading.net/ResultsVT.aspx")]
 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
 public class VTResults : System.Web.Services.WebService {
     public class Results {
         string Ticker;
         string BuyDate;
         decimal Buy;
         string SellDate;
         decimal Sell;
         string Profit;
         decimal Period;
     }
     [WebMethod]
     public Results[] GetResults() {
         string conn =                
 ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
    SqlConnection myconn = new SqlConnection(conn);
    SqlCommand mycomm = new SqlCommand();
    SqlDataAdapter myda = new SqlDataAdapter();
    DataSet myds = new DataSet();

    mycomm.CommandType = CommandType.StoredProcedure;
    mycomm.Connection = myconn;
    mycomm.CommandText = "dbo.Results";

    myconn.Open();
    myda.SelectCommand = mycomm;
    myda.Fill(myds);
    myconn.Close();
    myconn.Dispose();

    int i = 0;

    Results[] dts = new Results[myds.Tables[0].Rows.Count];
    foreach(DataRow arow in myds.Tables[0].Rows)
    {
        dts[i] = new Results();
        dts[i].Ticker = arow["Ticker"];
        dts[i].BuyDate = arow["BuyDate"];
        dts[1].Buy = arow["Buy"];
        dts[i].SellDate = arow["SellDate"];
        dts[i].Sell = arow["Sell"];
        dts[i].Profit = arow["Profit"];
        dts[i].Period = arow["Period"];
        i+=1;
    }
    return dts;
     }    
   }

The VB.NET WEBSERVICE that runs fine which I am trying to convert to C# is here.

 Imports System.Web
 Imports System.Web.Services
 Imports System.Web.Services.Protocols
 Imports System.Data
 Imports System.Data.SqlClient
 <WebService(Namespace:="http://localhost:2597/Results/ResultsVT.aspx")> _
 <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
 <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
 Public Class VTResults
     Inherits System.Web.Services.WebService
     Public Class Results
         Public Ticker As String
         Public BuyDate As String
         Public Buy As Decimal
         Public SellDate As String
         Public Sell As Decimal
         Public Profit As String
         Public Period As Decimal
     End Class
     <WebMethod()> _
     Public Function GetResults() As Results()
         Try
             Dim conn As String =  
 ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString
             Dim myconn = New SqlConnection(conn)
             Dim mycomm As New SqlCommand
             Dim myda As New SqlDataAdapter
             Dim myds As New DataSet

             mycomm.CommandType = CommandType.StoredProcedure
             mycomm.Connection = myconn
             mycomm.CommandText = "dbo.Results"

             myconn.Open()
             myda.SelectCommand = mycomm
             myda.Fill(myds)
             myconn.Close()
             myconn.Dispose()

             Dim i As Integer
             i = 0

             Dim dts As Results() = New Results(myds.Tables(0).Rows.Count - 1) {}
             Dim aRow As DataRow

             For Each aRow In myds.Tables(0).Rows
                 dts(i) = New Results
                 dts(i).Ticker = aRow("Ticker")
                 dts(i).BuyDate = aRow("BuyDate")
                 dts(i).Buy = aRow("Buy")
                 dts(i).SellDate = aRow("SellDate")
                 dts(i).Sell = aRow("Sell")
                 dts(i).Profit = aRow("Profit")
                 dts(i).Period = aRow("Period")
                 i += 1
             Next
             Return dts

         Catch ex As DataException
             Throw ex
         End Try
     End Function

 End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:29:44+00:00Added an answer on May 14, 2026 at 11:29 pm

    As everyone else already said, you need to make the members of Results public.

    Additionally, once you’ve done that, you’ll hit errors with the following lines:

        dts[i].Ticker = arow["Ticker"];
        dts[i].BuyDate = arow["BuyDate"];
        dts[1].Buy = arow["Buy"];
        dts[i].SellDate = arow["SellDate"];
        dts[i].Sell = arow["Sell"];
        dts[i].Profit = arow["Profit"];
        dts[i].Period = arow["Period"];
    

    The conversions in there work implicitly in VB.NET, but you’ll need to do them explicitly in C#

    e.g.

        dts[i].Ticker = arow["Ticker"].ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we do following in SQL Server 2005 query with convert function. MaxRegID =
Can you set the internal [[Class]] property of an ECMAScript object?
Can someone please help me figure out why my accordion script at http://www.mincovlaw.com/services/copyright gets
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can't figure out how to do this in a pretty way : I have
Can anyone tell me how to hide the header in DevExpress gridcontrol..?? I'm using
Can the Application Name passed to SQL Server (via the ADO Connection string) be
Can PHP PDO extension bind nested objects automatically ? I mean using foreign key
Can I register a .Net COM class with the SingleUse -flag? The reason I
can anyone tell me if it is possible to convert a dojo charting object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.