protected void btnLogIn_Click(object sender, EventArgs e)
    {
        string ID = Request.Form["txtID"];
        String password = Request.Form["txtPassword"];
        string strConString = ConfigurationManager.ConnectionStrings["SOConnectionString"].ConnectionString;
        OleDbConnection conn = new OleDbConnection(strConString);
        OleDbCommand cmd = new OleDbCommand("SELECT * FROM USERMASTER WHERE USERID =" + ID + "");

        try
        {

           // ClientScript.RegisterStartupScript(this.GetType(), "yourMessage", "alert('" + ID + " " + password + "');", true);
            conn.Open();
            OleDbDataReader dr;

            dr = cmd.ExecuteReader();
            txtID.Text = "test1";
            //txtPassword.Text = dr["UserPwd"].ToString();
            //OleDbDataReader dr;
            //while (dr.Read()){
            //    ClientScript.RegisterStartupScript(this.GetType(), "yourMessage", "alert('" + ID + " " + password + "');", true);
            //    txtPassword.Text = dr["UserPwd"].ToString();
            //}

        }
        catch (Exception ex)
        {
            txtID.Text = "ex";
            lbltest.Text = ex.ToString();


        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }

Exception:

System.InvalidOperationException: ExecuteReader: Connection property has not been initialized. at System.Data.OleDb.OleDbCommand.ValidateConnection(String method) at System.Data.OleDb.OleDbCommand.ValidateConnectionAndTransaction(String method) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.ExecuteReader() at _Default.btnLogIn_Click(Object sender, EventArgs e) in c:\Users\b2patso\Desktop\SO Maintainance\Default.aspx.cs:line 29

anyone know how what is the problem? I am using asp.net C# and visual studio 2013. db is oracle

Related posts

Recent Viewed