Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
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

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[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900