Click here to Skip to main content
14,668,470 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Mates

I want to find do i need to create a store procedure for this table on my database? Currently i do not have, could this be the reason for this exception?

What I have tried:

public string GetUserName_By_UserID(string UserId)
       {
           using(SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyString"].ToString())) {

               var para = new DynamicParameters();
               para.Add("@UserId", UserId);
               return con.Query<string>("Usp_GetUserName_By_UserID", para, null, true, 0, CommandType.StoredProcedure).SingleOrDefault();
           }
       }
Posted
Updated 22-Jan-20 3:29am
Comments
Richard MacCutchan 22-Jan-20 9:33am
   
The error message could not be more clear. Please at least try to do some basic investigation when you first see a problem.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

If you don't have a stored procedure usp_getusername_by_userid then of course you will get an error with that code.

Just create the stored procedure - what is the problem? Create a Stored Procedure - SQL Server | Microsoft Docs[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100