Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 :

C#
  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;
        }
}
}


C#
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
Comments
Sergey Alexandrovich Kryukov 11-Feb-13 3:58am    
???

1 solution

C#
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;
        }
}
}







C#
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;
            }
}
}
 
Share this answer
 
Comments
Rico_ 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)



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