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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:58:53+00:00 2026-06-11T03:58:53+00:00

I wrote a sql function which returns a scalar: 1 if the password is

  • 0

I wrote a sql function which returns a scalar: 1 if the password is correct, 0 otherwise.

   CREATE FUNCTION check_credential(  @User_IN nvarchar(50),  @Pwd_IN nvarchar(50)) 
   RETURNS int
   AS
   BEGIN
   DECLARE @PwdRES int
   DECLARE @PWD_DB varbinary(255)

   IF (@User_IN is not null and @User_IN != '' and @Pwd_IN is not null and @Pwd_IN != '' )
begin
    SELECT  @PWD_DB = password FROM myTable WHERE username = @User_IN
    SET @PwdRES = pwdcompare(@Pwd_IN, @PWD_DB )
end
ELSE
    SET @PwdRES = 0

   RETURN @PwdRES
   END

And this works correctly.

I’m using the following code for calling sql function:

    Dim conn As SqlConnection
    Dim sqlcmd As SqlCommand
    Dim da As SqlClient.SqlDataAdapter
    Dim table As DataTable
    Dim Result As Integer

    conn = New SqlConnection(ConnectionString)

    sqlcmd = New SqlClient.SqlCommand()
    sqlcmd.Connection = conn
    conn.Open()

    sqlcmd.CommandType = CommandType.StoredProcedure
    sqlcmd.CommandText = "check_credential"

    sqlcmd.Parameters.Add(New SqlClient.SqlParameter("@username", Utilities.NothingToDBNull(user)))
    sqlcmd.Parameters.Add(New SqlClient.SqlParameter("@password", Utilities.NothingToDBNull(password)))

At this point I want execute the sqlcmd and get the returning value.

  • 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-11T03:58:54+00:00Added an answer on June 11, 2026 at 3:58 am

    A function is different to a stored procedure

    Either convert your function to a stored procedure or change your command to

    "select dbo.check_credential(@username, @password)"
    

    set the CommandType as Text and use ExecuteScalar

    Result = Convert.ToInt32(cmd.ExecuteScalar())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to write one function which return sql statement like function get_sql($name=0,$date_start=0,$date_end=0)
I want to write a function in PL/SQL, which has a sql-statement as parameter.
Regarding to SQL performance. I have a scalar valued function for checking some specific
I'm currently trying to write a SQL Server 2005 function, which gets a string
I'm trying to create a function which references a temporary table in PostgreSQL 8.4.
We're having an issue with a poorly coded SQL function(which works fine in live,
string sqlQuery = unknown; I need to write a function which receives a sql
I have a c# function that needs to write to a SQL image column.
How do I write the YearFrac function that comes with Excel in Sql 2005?
I wrote a PL/SQL script to set a sequence's value to the maximum value

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.