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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:49:09+00:00 2026-05-11T05:49:09+00:00

Been using the code below to return a single record from the database. I

  • 0

Been using the code below to return a single record from the database. I have read that ExecuteScalar is the right way to return a single record. I have never been able to get ExecuteScalar to work though. How would I change this to return a single value in VB.Net using ExecuteScalar?

    Dim oracleConnection As New OracleConnection     oracleConnection.ConnectionString = LocalConnectionString()      Dim cmd As New OracleCommand()     Dim o racleDataAdapter As New OracleClient.OracleDataAdapter      cmd.Connection = oracleConnection     cmd.CommandText = 'FALCON.CMS_DATA.GET_MAX_CMS_TH'     cmd.CommandType = CommandType.StoredProcedure      cmd.Parameters.Add(New OracleParameter('i_FACID_C', OracleType.Char)).Value = facilityShortName     cmd.Parameters.Add(New OracleParameter('RS_MAX', OracleType.Cursor)).Direction = ParameterDirection.Output      Try         Using oracleConnection             oracleConnection.Open()             Using oracleDataAdapter                 oracleDataAdapter = New OracleClient.OracleDataAdapter(cmd)                  Dim workingDataSet As DataSet                 oracleDataAdapter.TableMappings.Add('OutputSH', 'RS_MAX')                 workingDataSet = New DataSet                 oracleDataAdapter.Fill(workingDataSet)                   For Each row As DataRow In workingDataSet.Tables(0).Rows                      Return CDate(row('MAXDATE'))                  Next             End Using         End Using 
  • 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. 2026-05-11T05:49:10+00:00Added an answer on May 11, 2026 at 5:49 am

    From Microsoft

    ‘The ExecuteOracleScalar() method of the OracleCommand class is used to execute a SQL statement or stored procedure that returns a single value as an OracleType data type. If the command returns a result set, the method returns the value of the first column of the first row. The method returns a null reference if a REF CURSOR is returned rather than the value of the first column of the first row to which the REF CURSOR points. The ExecuteScalar() method of the OracleCommand class is similar to the ExecuteOracleScalar() method, except it returns a value as a .NET Framework data type.

    Having said that, neither of these methods is useful when working with Oracle stored procedures. Oracle stored procedures cannot return a value as part of the RETURN statement, only as OUT parameters—see the Stored Procedures That Do Not Return Data section. Also, you cannot return a result set except through a REF CURSOR output parameter—this is discussed in the next section.

    You can retrieve the return value for an Oracle function only by using a RETURN parameter (shown in the previous section) and not by using the one of the ExecuteScalar methods.’

    http://msdn.microsoft.com/en-us/library/ms971506.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using code similar to this MessageDlg('', mtWarning, [mbOK], 0); throughout my
I've been using Javascript's Date for a project, but noticed today that my code
I have just been re-working an old bit of compiler-like code written using bison.
I've been using Subversion for code control with TortoiseSVN to interface with the server
I've been using the following code to open Office Documents, PDF, etc. on my
So far I've been using public void run() {} methods to execute my code
I've been doing code review (mostly using tools like FindBugs) of one of our
We have been using CruiseControl for quite a while with NUnit and NAnt. For
Been using PHP/MySQL for a little while now, and I'm wondering if there are
I've been using PHP & MySQL for ages and am about to start using

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.