Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WCF
Hi All ,
 
I am experiencing a small problem, I am trying to pass/send strings to another class within a project. Basically , I have formed 2 strings (to be inserted into a Database via a DAL class), so I am having trouble sending the strings across. Any help will be much appreciated. Code below :
 
  namespace SendFile
{
    public class File: IFile
    { 
 

     public string Insert(string InsertDLog, string InstrValue) //this method takes in 2 parameters , from here i need to send the strings to the DAL.cs
        {
 
            string InsertXMl = Insert.ToString();
            string Id = InstrValue.ToString();
 
            return null;
        }
}
}
 
 
namespace SendFile
{
    public static class DAL
    {
 
        public static void InsertDB()
        {
            
            string connection = ConfigurationManager.ConnectionStrings["DConnection"].ConnectionString;
            string StoredProc = ConfigurationManager.AppSettings["Insert_Update"];
            
            try
            {
                SqlConnection conn = new SqlConnection(connection);
                SqlCommand cmd = new SqlCommand(StoredProc,conn);
 
                cmd.CommandType = CommandType.StoredProcedure;
 

                cmd.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = null; // This value needs to be the ID from the Insert method (SendFile)
                cmd.Parameters.Add("@StatusID", SqlDbType.Int).Value = 1;
                cmd.Parameters.Add("@Message", SqlDbType.Xml).Value = null;// This value needs to be the InsertXMl from the Insert method (SendFile)

                conn.Open();
                cmd.ExecuteNonQuery();
 
            }
            catch (Exception ex)
            {
                throw ex;
            }
}
}
 
Thanks
Posted 10-Feb-13 22:48pm
Rico_5.7K
Comments
Sergey Alexandrovich Kryukov at 11-Feb-13 3:58am
   
???

1 solution

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

Solution 1

namespace SendFile
{
    public class File: IFile
    {
 

     public string Insert(string InsertDLog, string InstrValue) //this method takes in 2 parameters , from here i need to send the strings to the DAL.cs
        {
 
            string InsertXMl = Insert.ToString();
            string Id = InstrValue.ToString();
DAL.InsertDB(Id,InsertXMl );
 

            return null;
        }
}
}
 

 

 

namespace SendFile
{
    public static class DAL
    {
 
        public static void InsertDB(string Id , string InsertXMl )
        {
            
            string connection = ConfigurationManager.ConnectionStrings["DConnection"].ConnectionString;
            string StoredProc = ConfigurationManager.AppSettings["Insert_Update"];
            
            try
            {
                SqlConnection conn = new SqlConnection(connection);
                SqlCommand cmd = new SqlCommand(StoredProc,conn);
 
                cmd.CommandType = CommandType.StoredProcedure;
 
 
                cmd.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = Id ; // This value needs to be the ID from the Insert method (SendFile)
                cmd.Parameters.Add("@StatusID", SqlDbType.Int).Value = 1;
                cmd.Parameters.Add("@Message", SqlDbType.Xml).Value = InsertXMl ;// This value needs to be the InsertXMl from the Insert method (SendFile)

                conn.Open();
                cmd.ExecuteNonQuery();
 
            }
            catch (Exception ex)
            {
                throw ex;
            }
}
}
  Permalink  
Comments
Rico_ at 11-Feb-13 4:26am
   
Thanks Irbaz...Works 100%

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

  Print Answers RSS
0 OriginalGriff 6,803
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,421
3 Manas Bhardwaj 4,841
4 Maciej Los 4,330


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 11 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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