locked
error on linq onsubmit RRS feed

  • Question

  • User81789783 posted

    I have following code and i m m facing two error here. and error on below line

      obj.TBL_Departments.InsertOnSubmit(td);

    Error    14    The best overloaded method match for 'System.Data.Linq.Table<CallCenterCRM.TBL_Department>.InsertOnSubmit(CallCenterCRM.TBL_Department)' has some invalid arguments    C:\Users\erum\Documents\Visual Studio 2012\Projects\CallCenterCRM\CallCenterCRM\Models\TBL_Department.cs    134    11    CallCenterCRM

    Error    15    Argument 1: cannot convert from 'CallCenterCRM.Models.TBL_Department' to 'CallCenterCRM.TBL_Department'    C:\Users\erum\Documents\Visual Studio 2012\Projects\CallCenterCRM\CallCenterCRM\Models\TBL_Department.cs    134    46    CallCenterCRM

          public static  void  SaveDeptindb(TBL_Department dept)
            {
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
                
    
            
               CallCenterCRM.Models.TBL_Department td = new CallCenterCRM.Models.TBL_Department();            
      
    
                td.Department = dept.Department;
                td.Abbreviation = dept.Abbreviation;
                td.prefix = dept.prefix;
                td.EmpId = dept.EmpId;
    
              obj.TBL_Departments.InsertOnSubmit(td);
    
               
                obj.SubmitChanges();
             
               // return;
            }
    Tuesday, November 28, 2017 7:45 AM

Answers

  • User-335504541 posted

    Hi <g class="gr_ gr_5 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="5" data-gr-id="5">erum</g>,

    It seems you still have two TBL_Department. And the type in database is CallCenterCRM.TBL_Department.

    Please try to use the following code:

            public static  void  SaveDeptindb(TBL_Department dept)
            {
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
                CallCenterCRM.TBL_Department td = new CallCenterCRM.TBL_Department();
    td.Department = dept.Department; td.Abbreviation = dept.Abbreviation; td.prefix = dept.prefix; td.EmpId = dept.EmpId; obj.TBL_Departments.InsertOnSubmit(td); obj.SubmitChanges(); // return; }

    Best Regards,

    Billy

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 30, 2017 8:04 AM

All replies

  • User971510421 posted

    Hi Erum,

    you can do one thing as below as per the error message:

    Error: cannot convert from 'CallCenterCRM.Models.TBL_Department' to 'CallCenterCRM.TBL_Department' 

    Comment: Its look like there is some conversion issue like 'string' to 'int' or any other conversion required.

    I had faced the same problem when I was working on the same kind of insertion.

    Tuesday, November 28, 2017 10:20 AM
  • User81789783 posted

    still errro

    Error    14    The best overloaded method match for 'System.Data.Linq.Table<CallCenterCRM.TBL_Department>.InsertOnSubmit(CallCenterCRM.TBL_Department)' has some invalid arguments    C:\Users\erum\Documents\Visual Studio 2012\Projects\CallCenterCRM\CallCenterCRM\Models\TBL_Department.cs    134    11    CallCenterCRM

    Error    15    Argument 1: cannot convert from 'CallCenterCRM.Models.TBL_Department' to 'CallCenterCRM.TBL_Department'    C:\Users\erum\Documents\Visual Studio 2012\Projects\CallCenterCRM\CallCenterCRM\Models\TBL_Department.cs    134    46    CallCenterCRM

    though i have  remove null and check data type

    Tuesday, November 28, 2017 1:02 PM
  • User1120430333 posted

    Error    15    Argument 1: cannot convert from 'CallCenterCRM.Models.TBL_Department' to 'CallCenterCRM.TBL_Department'    C:\Users\erum\Documents\Visual Studio 2012\Projects\CallCenterCRM\CallCenterCRM\Models\TBL_Department.cs    134    46    CallCenterCRM

    You are being told what is wrong that is you cannot send 'CallCenterCRM.Models.TBL_Department' into the a method that wants 'CallCenterCRM.TBL_Department' The save method is trying to cast from one to the other.  .NET is not going to allow it to happen casting/converting an object across namespaces. TBL.Department and the namespace names proceeding TBL.Department are two different namespaces where those objects originate from,   and .NET is not going to make the cast it's not going to convert the objects.

    Tuesday, November 28, 2017 1:57 PM
  • User81789783 posted

    let me share model 'CallCenterCRM.Models.TBL_Department' 

    and callcentercrm (CallCenterCRMdbo.cs)  namespace class  ,Please note down i m using linq to sql class

    namespace CallCenterCRM
    {
        partial class TBL_AddressSetup
        {
        }
    
        partial class TBL_Department
        {
        }
    
        partial class CallCenterDboDataContext 
        {
            //public CallCenterDboDataContext()
            //    : base("CallCenterString")
            //{
    
    
            //}
        
    
    
        }
    }
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
     using System;
    using System.Data.Linq.Mapping;
    using System.Collections.Generic;
    using System.Linq;
    using System.Data.Entity;
    using System.Web;
    using System.Collections.Generic;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Web.Mvc;
    using System.Data.Linq;
    using CallCenterCRM.Models;
    using System;
    using System.Collections.Generic;
    using System.Data.Linq.Mapping;
    using System;
    using System.Collections.Generic;
    //using System.Linq;
    using System.Web;
    using System.Data.Linq.Mapping;
    
    
    namespace CallCenterCRM.Models
    {
          
      
        public interface IEmpRepository
        {
            IList<EmpMasterModel> ListAll();
        }
         //  public List<EmpMasterModel> Countries { get; set; }
          // private EmpMasterModel  l_oDbBO = new iRegDBContext(); 
       //  private CallDBEntities db = new TestDBEntities();  
    
        [Table(Name = "TBL_Department")]
        public  class TBL_Department
        {
            CallCenterDboDataContext dbContext = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa");
    
    
            //  EmpMasterModel _dataContext;
            //private EmpMasterModel _dataContext;
            public int DepartmentID { get; set; }
            public string prefix { get; set; }
            public string Department { get; set; }
    
            [Required]
            [Display(Name = "Abbreviation")]
            public string Abbreviation { get; set; }
            public Nullable<int> DeptInchargeID { get; set; }
    
    
            [Required(ErrorMessage = "Please select Employee")]
            [Range(1, int.MaxValue)]
            public int EmpId { get; set; }
    
            [Required]
            [Display(Name = "Employee")]
            public string Employee { get; set; }
    
            //public string Emp_FirstName { get; set; }
            //public string Emp_MiddleName { get; set; }
            //public string Emp_LastName { get; set; }
    
            public TBL_Department()
            {
    
            }
            public static IEnumerable<SelectListItem> GetAlldept()
            {
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
    
    
                var selectList = new List<SelectListItem>();
    
    
                foreach (var element in obj.TBL_Departments)
                {
                    selectList.Add(new SelectListItem
                    {
                        Value = Convert.ToInt32(element.DepartmentID).ToString(),
                        Text = element.Department 
                    });
                }
    
    
    
                return selectList;
            }
            public IEnumerable<SelectListItem> Employees { get; set; }
            public static IEnumerable<SelectListItem> GetEmployees()
            {
    
    
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
    
    
                var selectList = new List<SelectListItem>();
    
    
                foreach (var element in obj.TBL_EmpMasters)
                {
                    selectList.Add(new SelectListItem
                    {
                        Value = Convert.ToInt32(element.EmpId).ToString(),
                        Text = element.Emp_FirstName + " " + element.Emp_MiddleName + " " + element.Emp_LastName 
                    });
                }
    
    
    
                return selectList;
    
            }
    
            public static  void  SaveDeptindb(TBL_Department dept)
            {
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
                
    
            
               CallCenterCRM.Models.TBL_Department td = new CallCenterCRM.Models.TBL_Department();
    
               td.prefix = dept.prefix;
    
                td.Department = dept.Department;
                td.Abbreviation = dept.Abbreviation;
               
                td.DeptInchargeID = Convert.ToInt32(dept.Employee);
    
              obj.TBL_Departments.InsertOnSubmit(td);
    
               
                obj.SubmitChanges();
             
               // return;
            }
            public static IEnumerable<SelectListItem> GetPrefix()
            {
    
    
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
    
    
                var selectList = new List<SelectListItem>();
    
    
                foreach (var element in obj.TBL_Departments)
                {
                    selectList.Add(new SelectListItem
                    {
                        Value = Convert.ToInt32(element.prefix).ToString(),
                        Text = element.prefix.ToString()
                    });
                }
    
    
    
                return selectList;
    
            }
    
          //  public IEnumerable<TBL_Department> GetDept()
            public static List<TBL_Department> GetDeptbyprefix(string prefix)
            {
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
    
    
                // List<TBL_Department> DeptList = GetAlldept();
                //IEnumerable<TBL_Department> DeptList = GetDept();
                IList<TBL_Department> DeptList = GetDept();
    
                var depts =
                   ( from dept in DeptList
                    where dept.prefix == prefix select dept).ToList();
    
                foreach (var deptData in depts)
                {
    
                    DeptList.Add(new TBL_Department()
    
                    {
    
                        DepartmentID = deptData.DepartmentID,
    
                        Department = deptData.Department,
    
                        prefix = deptData.prefix
    
                    });
    
                }
                    //select new
                    //{
                    //    Department = dept.Department,
                    //    prefix = dept.prefix
    
                    //};
    
               // depts = DeptList.AsEnumerable<TBL_Department>();
               // return DeptList.ToList();
                return depts;
    
            }
            public static IList<TBL_Department> GetDept()
    
    
    
            {
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
    
    
                IList<TBL_Department> DeptList = new List<TBL_Department>();
    
                var query = from dept in obj.TBL_Departments
    
                            select dept;
    
                var depts = query.ToList();
    
                foreach (var deptData in obj.TBL_Departments)
                {
    
                   DeptList.Add(new TBL_Department()
    
                    {
    
                        DepartmentID = deptData.DepartmentID,
    
                        Department = deptData.Department,
    
                        prefix = deptData.prefix
    
                    });
    
                }
                return DeptList;
    
            }
           
            public static IEnumerable<SelectListItem> SelectAddressTYpe()
    
             {
                
                
                     CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
    
                  
                 var selectList = new List<SelectListItem>();
    
                
                foreach (var element in obj.TBL_AddressSetups)
                {
                    selectList.Add(new SelectListItem
                    {
                        Value = Convert.ToInt32(element.id).ToString(),
                        Text = element.Addresstype
                    });
                }
    
    
    
                return selectList;
               
        }
    
    
          public   void SaveDeptindb(CallCenterCRM.TBL_Department dept)
            {
              //  throw new NotImplementedException();
            }
        }
    
              //Create db context object here 
    
          
         //   EmpMasterModel dbContext = new EmpMasterModel();
       //  IEnumerable<SelectListItem> items = dbContext.Departments.Select(c => new SelectListItem
                
                    ////Here you can set 'Code' as the value field 
                    //Value = c.DepartmentID.ToString(),
                    //Text = c.GroupName
    
              
    
    
        
    
     
    }
    Wednesday, November 29, 2017 4:15 AM
  • User-335504541 posted

    Hi erum,

    namespace CallCenterCRM
    {
        partial class TBL_AddressSetup
        {
        }
    
        partial class TBL_Department
        {
        }
    
        partial class CallCenterDboDataContext 
        {
            //public CallCenterDboDataContext()
            //    : base("CallCenterString")
            //{
    
    
            //}
        
    
    
        }
    }

    It seems you have two TBL_Department in your code, TBL_Department in Model and TBL_Department in above code.

    And I think that is the reason for your error. You could try to remove the above TBL_Department.

    Please refer to the link below for using Linq to Sql class:

    https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/models-data/creating-model-classes-with-linq-to-sql-cs

    https://msdn.microsoft.com/en-us/library/bb384428.aspx

    Best Regards,

    Billy

    Wednesday, November 29, 2017 8:54 AM
  • User81789783 posted

    I re-created dbml and again facing but this time little different errors

    Error    14    The best overloaded method match for 'System.Data.Linq.Table<CallCenterCRM.TBL_Department>.InsertOnSubmit(CallCenterCRM.TBL_Department)' has some invalid arguments    C:\Users\erum\Documents\Visual Studio 2012\Projects\CallCenterCRM\CallCenterCRM\Models\TBL_Department.cs    135    11    CallCenterCRM

    Error    15    Argument 1: cannot convert from 'CallCenterCRM.Models.TBL_Department' to 'CallCenterCRM.TBL_Department'    C:\Users\erum\Documents\Visual Studio 2012\Projects\CallCenterCRM\CallCenterCRM\Models\TBL_Department.cs    135    46    CallCenterCRM

    Thursday, November 30, 2017 2:58 AM
  • User81789783 posted

    let me share designer file i.e  callcenterdbo.designer.cs

    #pragma warning disable 1591
    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:4.0.30319.18408
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------
    
    namespace CallCenterCRM
    {
    	using System.Data.Linq;
    	using System.Data.Linq.Mapping;
    	using System.Data;
    	using System.Collections.Generic;
    	using System.Reflection;
    	using System.Linq;
    	using System.Linq.Expressions;
    	using System.ComponentModel;
    	using System;
    	
    	
    	[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="CallCenter")]
    	public partial class CallCenterDboDataContext : System.Data.Linq.DataContext
    	{
    		
    		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
    		
        #region Extensibility Method Definitions
        partial void OnCreated();
        partial void InsertTBL_Department(TBL_Department instance);
        partial void UpdateTBL_Department(TBL_Department instance);
        partial void DeleteTBL_Department(TBL_Department instance);
        partial void InsertTBL_EmpMaster(TBL_EmpMaster instance);
        partial void UpdateTBL_EmpMaster(TBL_EmpMaster instance);
        partial void DeleteTBL_EmpMaster(TBL_EmpMaster instance);
        partial void InsertTBL_AddressSetup(TBL_AddressSetup instance);
        partial void UpdateTBL_AddressSetup(TBL_AddressSetup instance);
        partial void DeleteTBL_AddressSetup(TBL_AddressSetup instance);
        #endregion
    		
    		public CallCenterDboDataContext() : 
    				base(global::System.Configuration.ConfigurationManager.ConnectionStrings["CallCenterString"].ConnectionString, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public CallCenterDboDataContext(string connection) : 
    				base(connection, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public CallCenterDboDataContext(System.Data.IDbConnection connection) : 
    				base(connection, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public CallCenterDboDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
    				base(connection, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public CallCenterDboDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
    				base(connection, mappingSource)
    		{
    			OnCreated();
    		}
    		
    		public System.Data.Linq.Table<TBL_Department> TBL_Departments
    		{
    			get
    			{
    				return this.GetTable<TBL_Department>();
    			}
    		}
    		
    		public System.Data.Linq.Table<TBL_EmpMaster> TBL_EmpMasters
    		{
    			get
    			{
    				return this.GetTable<TBL_EmpMaster>();
    			}
    		}
    		
    		public System.Data.Linq.Table<TBL_AddressSetup> TBL_AddressSetups
    		{
    			get
    			{
    				return this.GetTable<TBL_AddressSetup>();
    			}
    		}
    	}
    	
    	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.TBL_Department")]
    	public partial class TBL_Department : INotifyPropertyChanging, INotifyPropertyChanged
    	{
    		
    		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    		
    		private int _DepartmentID;
    		
    		private string _prefix;
    		
    		private string _Department;
    		
    		private string _Abbreviation;
    		
    		private System.Nullable<int> _DeptInchargeID;
    		
        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnDepartmentIDChanging(int value);
        partial void OnDepartmentIDChanged();
        partial void OnprefixChanging(string value);
        partial void OnprefixChanged();
        partial void OnDepartmentChanging(string value);
        partial void OnDepartmentChanged();
        partial void OnAbbreviationChanging(string value);
        partial void OnAbbreviationChanged();
        partial void OnDeptInchargeIDChanging(System.Nullable<int> value);
        partial void OnDeptInchargeIDChanged();
        #endregion
    		
    		public TBL_Department()
    		{
    			OnCreated();
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DepartmentID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    		public int DepartmentID
    		{
    			get
    			{
    				return this._DepartmentID;
    			}
    			set
    			{
    				if ((this._DepartmentID != value))
    				{
    					this.OnDepartmentIDChanging(value);
    					this.SendPropertyChanging();
    					this._DepartmentID = value;
    					this.SendPropertyChanged("DepartmentID");
    					this.OnDepartmentIDChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_prefix", DbType="VarChar(50) NOT NULL", CanBeNull=false)]
    		public string prefix
    		{
    			get
    			{
    				return this._prefix;
    			}
    			set
    			{
    				if ((this._prefix != value))
    				{
    					this.OnprefixChanging(value);
    					this.SendPropertyChanging();
    					this._prefix = value;
    					this.SendPropertyChanged("prefix");
    					this.OnprefixChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Department", DbType="VarChar(50)")]
    		public string Department
    		{
    			get
    			{
    				return this._Department;
    			}
    			set
    			{
    				if ((this._Department != value))
    				{
    					this.OnDepartmentChanging(value);
    					this.SendPropertyChanging();
    					this._Department = value;
    					this.SendPropertyChanged("Department");
    					this.OnDepartmentChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Abbreviation", DbType="VarChar(50)")]
    		public string Abbreviation
    		{
    			get
    			{
    				return this._Abbreviation;
    			}
    			set
    			{
    				if ((this._Abbreviation != value))
    				{
    					this.OnAbbreviationChanging(value);
    					this.SendPropertyChanging();
    					this._Abbreviation = value;
    					this.SendPropertyChanged("Abbreviation");
    					this.OnAbbreviationChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_DeptInchargeID", DbType="Int")]
    		public System.Nullable<int> DeptInchargeID
    		{
    			get
    			{
    				return this._DeptInchargeID;
    			}
    			set
    			{
    				if ((this._DeptInchargeID != value))
    				{
    					this.OnDeptInchargeIDChanging(value);
    					this.SendPropertyChanging();
    					this._DeptInchargeID = value;
    					this.SendPropertyChanged("DeptInchargeID");
    					this.OnDeptInchargeIDChanged();
    				}
    			}
    		}
    		
    		public event PropertyChangingEventHandler PropertyChanging;
    		
    		public event PropertyChangedEventHandler PropertyChanged;
    		
    		protected virtual void SendPropertyChanging()
    		{
    			if ((this.PropertyChanging != null))
    			{
    				this.PropertyChanging(this, emptyChangingEventArgs);
    			}
    		}
    		
    		protected virtual void SendPropertyChanged(String propertyName)
    		{
    			if ((this.PropertyChanged != null))
    			{
    				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    			}
    		}
    	}
    	
    	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.TBL_EmpMaster")]
    	public partial class TBL_EmpMaster : INotifyPropertyChanging, INotifyPropertyChanged
    	{
    		
    		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    		
    		private int _EmpId;
    		
    		private string _Emp_FirstName;
    		
    		private string _Emp_MiddleName;
    		
    		private string _Emp_LastName;
    		
    		private System.Nullable<System.DateTime> _Emp_DOB;
    		
    		private System.Nullable<System.DateTime> _Emp_DOJ;
    		
    		private string _Emp_HighestQualification;
    		
    		private System.Nullable<int> _Emp_DeptId;
    		
    		private System.Nullable<int> _Emp_DesgID;
    		
    		private System.Nullable<int> _Emp_ManagerId;
    		
    		private System.Nullable<int> _Emp_Gender;
    		
    		private System.Nullable<int> _Emp_MartialStatus;
    		
    		private System.Data.Linq.Binary _Emp_photo;
    		
    		private string _Emp_photoFilename;
    		
        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnEmpIdChanging(int value);
        partial void OnEmpIdChanged();
        partial void OnEmp_FirstNameChanging(string value);
        partial void OnEmp_FirstNameChanged();
        partial void OnEmp_MiddleNameChanging(string value);
        partial void OnEmp_MiddleNameChanged();
        partial void OnEmp_LastNameChanging(string value);
        partial void OnEmp_LastNameChanged();
        partial void OnEmp_DOBChanging(System.Nullable<System.DateTime> value);
        partial void OnEmp_DOBChanged();
        partial void OnEmp_DOJChanging(System.Nullable<System.DateTime> value);
        partial void OnEmp_DOJChanged();
        partial void OnEmp_HighestQualificationChanging(string value);
        partial void OnEmp_HighestQualificationChanged();
        partial void OnEmp_DeptIdChanging(System.Nullable<int> value);
        partial void OnEmp_DeptIdChanged();
        partial void OnEmp_DesgIDChanging(System.Nullable<int> value);
        partial void OnEmp_DesgIDChanged();
        partial void OnEmp_ManagerIdChanging(System.Nullable<int> value);
        partial void OnEmp_ManagerIdChanged();
        partial void OnEmp_GenderChanging(System.Nullable<int> value);
        partial void OnEmp_GenderChanged();
        partial void OnEmp_MartialStatusChanging(System.Nullable<int> value);
        partial void OnEmp_MartialStatusChanged();
        partial void OnEmp_photoChanging(System.Data.Linq.Binary value);
        partial void OnEmp_photoChanged();
        partial void OnEmp_photoFilenameChanging(string value);
        partial void OnEmp_photoFilenameChanged();
        #endregion
    		
    		public TBL_EmpMaster()
    		{
    			OnCreated();
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_EmpId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    		public int EmpId
    		{
    			get
    			{
    				return this._EmpId;
    			}
    			set
    			{
    				if ((this._EmpId != value))
    				{
    					this.OnEmpIdChanging(value);
    					this.SendPropertyChanging();
    					this._EmpId = value;
    					this.SendPropertyChanged("EmpId");
    					this.OnEmpIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_FirstName", DbType="VarChar(50)")]
    		public string Emp_FirstName
    		{
    			get
    			{
    				return this._Emp_FirstName;
    			}
    			set
    			{
    				if ((this._Emp_FirstName != value))
    				{
    					this.OnEmp_FirstNameChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_FirstName = value;
    					this.SendPropertyChanged("Emp_FirstName");
    					this.OnEmp_FirstNameChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_MiddleName", DbType="VarChar(50)")]
    		public string Emp_MiddleName
    		{
    			get
    			{
    				return this._Emp_MiddleName;
    			}
    			set
    			{
    				if ((this._Emp_MiddleName != value))
    				{
    					this.OnEmp_MiddleNameChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_MiddleName = value;
    					this.SendPropertyChanged("Emp_MiddleName");
    					this.OnEmp_MiddleNameChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_LastName", DbType="VarChar(50)")]
    		public string Emp_LastName
    		{
    			get
    			{
    				return this._Emp_LastName;
    			}
    			set
    			{
    				if ((this._Emp_LastName != value))
    				{
    					this.OnEmp_LastNameChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_LastName = value;
    					this.SendPropertyChanged("Emp_LastName");
    					this.OnEmp_LastNameChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_DOB", DbType="DateTime")]
    		public System.Nullable<System.DateTime> Emp_DOB
    		{
    			get
    			{
    				return this._Emp_DOB;
    			}
    			set
    			{
    				if ((this._Emp_DOB != value))
    				{
    					this.OnEmp_DOBChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_DOB = value;
    					this.SendPropertyChanged("Emp_DOB");
    					this.OnEmp_DOBChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_DOJ", DbType="DateTime")]
    		public System.Nullable<System.DateTime> Emp_DOJ
    		{
    			get
    			{
    				return this._Emp_DOJ;
    			}
    			set
    			{
    				if ((this._Emp_DOJ != value))
    				{
    					this.OnEmp_DOJChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_DOJ = value;
    					this.SendPropertyChanged("Emp_DOJ");
    					this.OnEmp_DOJChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_HighestQualification", DbType="VarChar(50)")]
    		public string Emp_HighestQualification
    		{
    			get
    			{
    				return this._Emp_HighestQualification;
    			}
    			set
    			{
    				if ((this._Emp_HighestQualification != value))
    				{
    					this.OnEmp_HighestQualificationChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_HighestQualification = value;
    					this.SendPropertyChanged("Emp_HighestQualification");
    					this.OnEmp_HighestQualificationChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_DeptId", DbType="Int")]
    		public System.Nullable<int> Emp_DeptId
    		{
    			get
    			{
    				return this._Emp_DeptId;
    			}
    			set
    			{
    				if ((this._Emp_DeptId != value))
    				{
    					this.OnEmp_DeptIdChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_DeptId = value;
    					this.SendPropertyChanged("Emp_DeptId");
    					this.OnEmp_DeptIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_DesgID", DbType="Int")]
    		public System.Nullable<int> Emp_DesgID
    		{
    			get
    			{
    				return this._Emp_DesgID;
    			}
    			set
    			{
    				if ((this._Emp_DesgID != value))
    				{
    					this.OnEmp_DesgIDChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_DesgID = value;
    					this.SendPropertyChanged("Emp_DesgID");
    					this.OnEmp_DesgIDChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_ManagerId", DbType="Int")]
    		public System.Nullable<int> Emp_ManagerId
    		{
    			get
    			{
    				return this._Emp_ManagerId;
    			}
    			set
    			{
    				if ((this._Emp_ManagerId != value))
    				{
    					this.OnEmp_ManagerIdChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_ManagerId = value;
    					this.SendPropertyChanged("Emp_ManagerId");
    					this.OnEmp_ManagerIdChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_Gender", DbType="Int")]
    		public System.Nullable<int> Emp_Gender
    		{
    			get
    			{
    				return this._Emp_Gender;
    			}
    			set
    			{
    				if ((this._Emp_Gender != value))
    				{
    					this.OnEmp_GenderChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_Gender = value;
    					this.SendPropertyChanged("Emp_Gender");
    					this.OnEmp_GenderChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_MartialStatus", DbType="Int")]
    		public System.Nullable<int> Emp_MartialStatus
    		{
    			get
    			{
    				return this._Emp_MartialStatus;
    			}
    			set
    			{
    				if ((this._Emp_MartialStatus != value))
    				{
    					this.OnEmp_MartialStatusChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_MartialStatus = value;
    					this.SendPropertyChanged("Emp_MartialStatus");
    					this.OnEmp_MartialStatusChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_photo", DbType="Image", UpdateCheck=UpdateCheck.Never)]
    		public System.Data.Linq.Binary Emp_photo
    		{
    			get
    			{
    				return this._Emp_photo;
    			}
    			set
    			{
    				if ((this._Emp_photo != value))
    				{
    					this.OnEmp_photoChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_photo = value;
    					this.SendPropertyChanged("Emp_photo");
    					this.OnEmp_photoChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Emp_photoFilename", DbType="VarChar(50)")]
    		public string Emp_photoFilename
    		{
    			get
    			{
    				return this._Emp_photoFilename;
    			}
    			set
    			{
    				if ((this._Emp_photoFilename != value))
    				{
    					this.OnEmp_photoFilenameChanging(value);
    					this.SendPropertyChanging();
    					this._Emp_photoFilename = value;
    					this.SendPropertyChanged("Emp_photoFilename");
    					this.OnEmp_photoFilenameChanged();
    				}
    			}
    		}
    		
    		public event PropertyChangingEventHandler PropertyChanging;
    		
    		public event PropertyChangedEventHandler PropertyChanged;
    		
    		protected virtual void SendPropertyChanging()
    		{
    			if ((this.PropertyChanging != null))
    			{
    				this.PropertyChanging(this, emptyChangingEventArgs);
    			}
    		}
    		
    		protected virtual void SendPropertyChanged(String propertyName)
    		{
    			if ((this.PropertyChanged != null))
    			{
    				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    			}
    		}
    	}
    	
    	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.TBL_AddressSetup")]
    	public partial class TBL_AddressSetup : INotifyPropertyChanging, INotifyPropertyChanged
    	{
    		
    		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
    		
    		private int _id;
    		
    		private string _Addresstype;
    		
        #region Extensibility Method Definitions
        partial void OnLoaded();
        partial void OnValidate(System.Data.Linq.ChangeAction action);
        partial void OnCreated();
        partial void OnidChanging(int value);
        partial void OnidChanged();
        partial void OnAddresstypeChanging(string value);
        partial void OnAddresstypeChanged();
        #endregion
    		
    		public TBL_AddressSetup()
    		{
    			OnCreated();
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
    		public int id
    		{
    			get
    			{
    				return this._id;
    			}
    			set
    			{
    				if ((this._id != value))
    				{
    					this.OnidChanging(value);
    					this.SendPropertyChanging();
    					this._id = value;
    					this.SendPropertyChanged("id");
    					this.OnidChanged();
    				}
    			}
    		}
    		
    		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Addresstype", DbType="VarChar(50)")]
    		public string Addresstype
    		{
    			get
    			{
    				return this._Addresstype;
    			}
    			set
    			{
    				if ((this._Addresstype != value))
    				{
    					this.OnAddresstypeChanging(value);
    					this.SendPropertyChanging();
    					this._Addresstype = value;
    					this.SendPropertyChanged("Addresstype");
    					this.OnAddresstypeChanged();
    				}
    			}
    		}
    		
    		public event PropertyChangingEventHandler PropertyChanging;
    		
    		public event PropertyChangedEventHandler PropertyChanged;
    		
    		protected virtual void SendPropertyChanging()
    		{
    			if ((this.PropertyChanging != null))
    			{
    				this.PropertyChanging(this, emptyChangingEventArgs);
    			}
    		}
    		
    		protected virtual void SendPropertyChanged(String propertyName)
    		{
    			if ((this.PropertyChanged != null))
    			{
    				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    			}
    		}
    	}
    }
    #pragma warning restore 1591
    
    Thursday, November 30, 2017 3:01 AM
  • User-335504541 posted

    Hi <g class="gr_ gr_5 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="5" data-gr-id="5">erum</g>,

    It seems you still have two TBL_Department. And the type in database is CallCenterCRM.TBL_Department.

    Please try to use the following code:

            public static  void  SaveDeptindb(TBL_Department dept)
            {
                CallCenterDboDataContext obj = new CallCenterDboDataContext("Data Source=erum-pc;Initial Catalog=CallCenter;User ID=sa;Password=sa;");
                CallCenterCRM.TBL_Department td = new CallCenterCRM.TBL_Department();
    td.Department = dept.Department; td.Abbreviation = dept.Abbreviation; td.prefix = dept.prefix; td.EmpId = dept.EmpId; obj.TBL_Departments.InsertOnSubmit(td); obj.SubmitChanges(); // return; }

    Best Regards,

    Billy

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 30, 2017 8:04 AM
  • User81789783 posted

    thanks done

    Billy Liu

    Thursday, November 30, 2017 8:25 AM