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 8020219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:37:33+00:00 2026-06-04T21:37:33+00:00

So I’m not sure if there is a better way to do this, but

  • 0

So I’m not sure if there is a better way to do this, but here is my current setup.

  1. Created an XSD file that represents my table structure from my database.
  2. Created a class file to hold my functions such as the one below.

Code sample:

Public Function GetUser(ByVal UserID As String) As xsdUser.UserDataTable

        Dim SqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings("MyDatabase").ConnectionString)
        Dim SqlCom = New SqlCommand("User_Retrieve", SqlConn)
        Dim Adapter As SqlDataAdapter
        Dim UserDT As New xsdUser.UserDataTable

        Using SqlCom
            SqlCom.Parameters.Add(New SqlParameter("@I_UserID", SqlDbType.NVarChar, 4)).Value = UserID
            Adapter = New SqlDataAdapter(SqlCom)
            Adapter.Fill(UserDT)
        End Using

        If UserDT IsNot Nothing AndAlso UserDT.Rows.Count > 0 Then    
             'Return DataTable here or I guess DataRow since there should just be one.
        Else
             'Handle Error here if there is no row
        End If
End Function

Now it seems odd to me to have two files doing what should be contained within just one file. I feel like I should have one class file called “User” and have member variables in there along with the class functions like the one above. But all the tutorials I see are using these data tables. On top of that I’m not sure how to handle the if statement at the end of the function. I don’t think I would want to return a whole DataTable since I should only have one row, and I also don’t know how I would handle an error if my function is supposed to return a data table. I suppose I could return an empty one and then if the table is empty in my code then I would handle it there, but this also seems messy.

So can anyone clear up some of these things? Is this the common way of retrieving information from a stored procedure? Or is there a more up-to-date method that I’m not seeing in my search results?

Thanks!

  • 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-06-04T21:37:34+00:00Added an answer on June 4, 2026 at 9:37 pm

    Returning the UserDataTable is perfectly acceptable. Even if it contains just one row.
    The only thing that seem out of order is your check the result inside this method that belongs to a lower layer than the user interface. Also note that you don’t need to check if the UserDataTable is nothing.

    And I think this line is required

     SqlCom.CommandType = CommandType.StoredProcedure
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I need a function that will clean a strings' special characters. I do NOT
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but

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.