Click here to Skip to main content
15,844,498 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,

I am busy building a windows forms application that needs to be able to use a WCF to connect to the work Database.

I get how to reference it but now I was told to create a DAL project and Classes project to contain all my methods and that's where I get really confused because my Classes.cs has SQL commands in it and now I have to call the method in the WCF and then get that method in the app it self here is the code that I use in the classes.cs but how would I then reference this in the WCF and then to the App it self via code?
C#
private DataTable getLoginDetails(string username)
        {

            
            SqlCommand sqlcmd = new SqlCommand("sp_GetLoginDetails", sqlConn);
            sqlcmd.CommandType = CommandType.StoredProcedure;

            sqlcmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = username;
            DataTable dtUser = new DataTable();
            sqlConn.Open();
            SqlDataReader sqlDR = sqlcmd.ExecuteReader();
            dtUser.Load(sqlDR);
            sqlConn.Close();

            BGAssetService.Service1Client serviceAsset = new BGAssetService.Service1Client();
            serviceAsset.GetLoginDetails(username);            

            return dtUser;
            
        }
Posted
Updated 3-Dec-13 6:16am
v2
Comments
johannesnestler 22-Apr-15 10:43am    
I don't understand what's your problem. Can you try to describe your scenario better?
Do you just want to call the Service from your "DAL", or should the "DAL" be a WCF-Service you can call from client side?
If you know how to "reference" your WCF-Service so you can call it, I can't imagine what hinders you to do the same from another roject (your new class-library)?

1 solution

1. Create OperationContracts and DataContracts
2. Update your service Reference.
3. Create WCF client in your app
4. You'll get the method refernce
 
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