Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please any help, im trying to use var in public class its not working, saying invalid initializer member declarator.

What I have tried:

public class SqlConnector : IDataConnection
   {
       // TODO Wire up the create text file

       public PrizeModel CreatePrize(PrizeModel model)
       {
           using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments"))
           {
               var p= new DynamicParameters();
                  p.Add("@placenumber", model.placenumber);
                  p.Add("@placename", model.placename);
           }
       }
   }


im using dapper. please if i can't use this, are there any fix as i am trying to call a stored procedure to insert hoe parameters
i am using visual studio 2019
Posted
Updated 21-Jun-20 7:46am
v2
Comments
Richard MacCutchan 21-Jun-20 4:19am    
Exactly which line gives the error?
Richard MacCutchan 21-Jun-20 13:01pm    
No, it's probably the reason given below by 0x01AA.
[no name] 21-Jun-20 5:56am    
Missing closing bracket?

using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments")))
Tobynate 21-Jun-20 13:02pm    
thanks a bunch, i really didnt notice but that was the problem, much love
[no name] 21-Jun-20 14:02pm    
You are very welcome.

Now I did not expected that only the missing closing bracket was the problem. But according to OP's comment above it was.

using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments"))

needs to be
using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("Tournaments")))

Usually such an error will be reported by compiler by "')' expected".

Nevertheless solved.
 
Share this answer
 
Comments
Maciej Los 22-Jun-20 4:43am    
5ed!
[no name] 22-Jun-20 8:21am    
Thank you Maciej
 
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