locked
entityexception was unhandled RRS feed

  • Question

  • /*--------------------------------------------------------------------------------------------------------------*/
    // PROGRAMMER: G Prathab Kumar
    // REFERENCES: VISUAL C# PROGRAMMING BY: Sekar R K
    //             VISUAL BASIC .NET HOW TO PROGRAM BY: Prathab kumar
    // PURPOSE: 
    // LANGUAGE: C# .NET
    /*--------------------------------------------------------------------------------------------------------------*/
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using SalesAndMonitoring.Database;
    
    namespace SalesAndMonitoring
    {
        public partial class frmLogin : Form
        {
            private string User = "";
            private bool isvalid = false;
            private string[] privileges;
    
            public string[] Privileges
            {
                get { return privileges; }
            }
    
            public string getUser
            {
                get { return User; }
            }
    
            public bool isValid
            {
                get { return isvalid; }
            }
    
            //Use to validate user login entry
              private void sValidate()
            {
                var user =
                    BusinessAccessLayer.GetEntity().User_tbl.Where(
                        e => e.UserID == txtUsername.Text && e.Password == txtPassword.Text);
    
    
                if(user.Count() >0 )
                {
                    isvalid = true;
                    User = txtUsername.Text;
                    Close();
                    return;
                }
    
                MessageBox.Show("Invalid username or password", "invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
    
    
            //---------------------------------------------//
    
            //Constructor()
            public frmLogin()
            {
                InitializeComponent();
                txtUsername.Focus();
            }
    
            private void btnCancel_Click(object sender, EventArgs e)
            {
                DialogResult rs = MessageBox.Show("Are you sure you want to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (rs == DialogResult.No) { return; }
                Application.Exit();
            }
    
            private void btnLOGIN_Click(object sender, EventArgs e)
            {
                sValidate();
            }
    
        }
    }

    CSS MSDN Team ya this what it look like  see the image too  

    my email : svktutorial@gmail.com,svktutorial@hotmail.com


    Saturday, August 18, 2012 12:08 PM

Answers

  • Hi,

    It seems to me "the underlying provider failed on open". It seems EF can't properly open the connection (missing file or bad connection string ?).

    Posting an image doesn't really help (or at least just post the relevant part to keep it legible). Also always check the inner exception to get at the root cause (ie use the "View details" option shown on your screen).


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by prathab Tuesday, August 21, 2012 2:47 AM
    Saturday, August 18, 2012 12:25 PM
  • Hi prathab;

    Is BusinessAccessLayer in a different project then where you are getting the exception? If so did you copy the connection string from the app.config file from the BusinessAccessLayer to the app.config file of the project you are getting the error in?

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by prathab Tuesday, August 21, 2012 2:47 AM
    Saturday, August 18, 2012 2:52 PM

All replies

  • Hi,

    It seems to me "the underlying provider failed on open". It seems EF can't properly open the connection (missing file or bad connection string ?).

    Posting an image doesn't really help (or at least just post the relevant part to keep it legible). Also always check the inner exception to get at the root cause (ie use the "View details" option shown on your screen).


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by prathab Tuesday, August 21, 2012 2:47 AM
    Saturday, August 18, 2012 12:25 PM
  • Hi prathab;

    Is BusinessAccessLayer in a different project then where you are getting the exception? If so did you copy the connection string from the app.config file from the BusinessAccessLayer to the app.config file of the project you are getting the error in?

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by prathab Tuesday, August 21, 2012 2:47 AM
    Saturday, August 18, 2012 2:52 PM