Wednesday 12 August 2015

How to Use a edmx file for multiple DB having same type of table and schema.

1.There are 3 database are have same type of table for 3 application.


Tables are

2.Another database to manage the applications  having a table to store the Application ID ,server name,DBname,Password and username  of application database.






3. create a Edmx file for a Application that will work as a template and another
 for the DB to manage Application



                                                           (for manage applications)
4.while creating the edmx file the class  generate by edmx file is

5. Create a class of same class name as above with a parameterized constructor to pass the connection string to this for change the Db connection string dynamically .


6. based on the application id we will get the database detail and pass to the function to change the connection string .

 Copy the connection  string for applicationDB from web.config file and put that in a string and change the server name, DBname, Password and username  of application based on Appid.

7.GetuserDBbyAppid() function we will get the entity for the particular DB .then we can use the Entity Framework to curd operation on that DB.
Like

USE of this:
 Need not required to create edmx file for same type of database which are situated in different servers and all server can manage through a application means we can create users in base application so that user can login in assigned application .



thanks ,
Pradeep Kumar Das 

Tuesday 20 January 2015

When we sending mail if you trouble shooting with this Error

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at + working on one gmail account.

To solve this Error just go to this links

https://accounts.google.com/DisplayUnlockCaptcha
https://www.google.com/settings/security/lesssecureapps

Code for Sending Email:

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
        mail.To.Add("Toaddress");
        mail.From = new MailAddress("from mail", "Email head", System.Text.Encoding.UTF8);
        mail.Subject = "This mail is send from asp.net application";
        mail.SubjectEncoding = System.Text.Encoding.UTF8;
        mail.Body = "This is Email Body Text";
        mail.BodyEncoding = System.Text.Encoding.UTF8;
        mail.IsBodyHtml = true;
        mail.Priority = MailPriority.High;

        SmtpClient client = new SmtpClient();
       // client.EnableSsl = true;
        client.UseDefaultCredentials = false;

        client.Credentials = new System.Net.NetworkCredential("from mail", "from mail Password");
        client.Port = 587;
        client.Host = "smtp.gmail.com";
        client.EnableSsl = true;
       
        try
        {
            client.Send(mail);
        }
        catch (Exception ex)
        {
            throw;

        }

Reference Link:
http://forums.asp.net/t/2021213.aspx?sending+email+via+gmail+not+working+authentication+problem

If you have any Queries please contact lakshmibindu.cse@gmail.com