Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
gridview1 inside modalpopupextender1 with a linkbutton opens another modalpopupextender2 with gridview2.
now when i am clicking linkbutton of gridview1 which is inside modalpopextender1 ....modalpopupextender2 does not popup ...and not even showing any errors...its just when i inspect the element in browser and it says

"
C#
206|error|500|ERROR [HY000] [MySQL][ODBC 3.51 Driver]Access denied for user 'ODBC'@'localhost' (using password: YES)

"

My webconfig file:
C#
<add name="connect3" connectionstring="DRIVER={MySQL ODBC 3.51 Driver};  Host=localhost;UserName=root;Password=*****;Database=welco1_all" />
      <add name="connect4" connectionstring="DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; UID=root; PASSWORD=12345; OPTION=3" />


I tried almost everything ...but nothing good come....any help is highly appreciated...

What I have tried:

This is my HTML file:
C#
<%--Master Button--%>
    <asp:gridview runat="server" id="GridView1" showfooter="true" 
        autogeneratecolumns="false" GridLines="None" CssClass="table1"  
          
        OnRowCreated="GridView1_RowCreated" BorderColor="#356600" 
        BorderStyle="Solid" >
        <columns>
           
           <asp:TemplateField HeaderText="Date" >
<ItemTemplate>
<asp:LinkButton ID="Date" runat="server" CausesValidation="false"  CommandName="Date_Select"  Text='<%#Eval("Date","{0:yyyy-MM-dd}") %>' onclick="Date_Click"  ></asp:LinkButton>

    
</ItemTemplate>
<EditItemTemplate>

</EditItemTemplate>
</asp:TemplateField>


             <asp:boundfield datafield="" headertext="Total" footerstyle-font-bold="true"  
                footertext="Grand Total:" >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
            
            <asp:boundfield datafield="MIns" headertext="Mins" 
                footerstyle-font-bold="true"   >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
            <asp:boundfield datafield="Amount" headertext="Amount" footerstyle-font-bold="true"  
                 >
<FooterStyle Font-Bold="True" ></FooterStyle>
            </asp:boundfield>
           
            <asp:boundfield datafield="Profit" headertext="Profit"
                footerstyle-font-bold="true">
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
            
       </columns>

<HeaderStyle BackColor="#CEFF99" ForeColor="Black" BorderColor="#C1FF80" BorderStyle="Solid" 
                  BorderWidth="1px"></HeaderStyle>

<RowStyle CssClass="td"></RowStyle>
    </asp:gridview>
    <%--Hidden Button--%>
    <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
    <%--Modalpopup extender For Parent--%>
    <ccl:ModalPopupExtender ID="mdlPopup"  runat="server" TargetControlID="btnShowPopup"
        PopupControlID="pnlParent" CancelControlID="btnClose" BackgroundCssClass="modalBackground">
    </ccl:ModalPopupExtender>
    
    <%--Parent Panel--%>
    <asp:Panel ID="pnlParent" Style="display: none; position: absolute; width: 500px;
        border: solid 1px black; height: 630px; width:800px; background-color: White; margin-left: 50px"
        runat="server" CssClass="modalpopup">
        <asp:UpdatePanel ID="updateParent" runat="Server">
            <ContentTemplate>
                
                            <div style ="height:630px; width:800px; overflow:auto;">
          
<asp:gridview runat="server" id="GridView17" showfooter="true" 
        autogeneratecolumns="false" GridLines="None" CssClass="table" 
        HeaderStyle-CssClass="th" RowStyle-CssClass="td" Width="100%" 
         AllowPaging="false" ShowHeader="true">
        <columns>
           <asp:TemplateField HeaderText="Date" >
<ItemTemplate>
<asp:LinkButton ID="Customer" runat="server" CausesValidation="false"  CommandName="Date_Select"  Text='<%#Eval("Customer") %>' onclick="Customer_Click" ></asp:LinkButton>

    
</ItemTemplate>
<EditItemTemplate>

</EditItemTemplate>
</asp:TemplateField>
            <%--<asp:boundfield datafield="Customer" headertext="Customer"  ItemStyle-HorizontalAlign="Left"
                footerstyle-font-bold="true" ItemStyle-Width="200px"   >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>--%>
           

             <asp:boundfield datafield="MIns" headertext="Mins" footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px">
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
            <asp:boundfield datafield="Amount" headertext="Amount" 
                footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px"  >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
            <asp:boundfield datafield="Profit" headertext="Profit" footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px"
                 >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
           
            
            
       </columns>

<HeaderStyle BackColor="#CEFF99" ForeColor="Black" BorderColor="#C1FF80" BorderStyle="Solid" 
                  BorderWidth="1px"></HeaderStyle>

<RowStyle CssClass="td"></RowStyle>
    </asp:gridview>
    </div>
                        
                <%--Close Button For Parent Modal Popup--%>
                <asp:Button ID="btnClose" runat="server" Text="Close" OnClientClick="$find('mdlPopup').hide(); return false;" />
                <%--Target Control Button For Child Modal--%>
                <asp:Button ID="btnChildTarget" runat="server" Style="display: none" />
                <ccl:ModalPopupExtender ID="mdlChild"  runat="server" TargetControlID="btnChildTarget"
                    PopupControlID="pnlChild" CancelControlID="btnCloseChild" BackgroundCssClass="modalBackground">
                </ccl:ModalPopupExtender>
                <asp:Panel runat="server" ID="pnlChild" Style="display: none; width: 100%; border: solid 1px black;
                    height: 100%; background-color: White; margin-left: 10px">
                   
                               <div style ="height:630px; width:800px; overflow:auto;">
          
<asp:gridview runat="server" id="GridView34" showfooter="true" 
        autogeneratecolumns="false" GridLines="None" CssClass="table" 
        HeaderStyle-CssClass="th" RowStyle-CssClass="td" Width="100%" 
         AllowPaging="false" ShowHeader="true">
        <columns>
           
           

            <asp:boundfield datafield="Vendor" headertext="Vendor"  ItemStyle-HorizontalAlign="Left"
                footerstyle-font-bold="true" ItemStyle-Width="200px"   >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
           

             <asp:boundfield datafield="Region" headertext="Region" footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px">
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
            <asp:boundfield datafield="MIns" headertext="Mins" 
                footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px"  >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
            <asp:boundfield datafield="Amount" headertext="Amount" footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px"
                 >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>

            <asp:boundfield datafield="V_Mins" headertext="V_Mins" footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px"
                 >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
            
            <asp:boundfield datafield="V_Amount" headertext="V_Amount" footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px"
                 >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>

            <asp:boundfield datafield="profit" headertext="Profit" footerstyle-font-bold="true" ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px"
                 >
<FooterStyle Font-Bold="True"></FooterStyle>
            </asp:boundfield>
           
            
            
       </columns>

<HeaderStyle BackColor="#CEFF99" ForeColor="Black" BorderColor="#C1FF80" BorderStyle="Solid" 
                  BorderWidth="1px"></HeaderStyle>

<RowStyle CssClass="td"></RowStyle>
    </asp:gridview>
    </div>
                            
                    <asp:Button ID="btnCloseChild" runat="server" Text="Close" OnClientClick="$find('mdlChild').hide(); return false;" />
                    <%--<asp:Button ID="btnChild" runat="server" OnClick="btnChild_Click" Text="Send Value To Parent" />--%></asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>


And this is my .CS file:
C#
protected void Date_Click(object sender, EventArgs e)
  {

      LinkButton Lnk = (LinkButton)sender;
      //Label2.Text = Lnk.Text;
      TextBox1.Text = Lnk.Text;
      //date = TextBox1.Text;
      //TextBox3.Text = Lnk.Text;
      OdbcConnection con1 = new OdbcConnection(ConfigurationManager.ConnectionStrings["connect1"].ConnectionString);
      OdbcCommand cmd = new OdbcCommand("select a.customer As Customer,a.mins as MIns,a.amount as Amount,a.profit as Profit from summarydatashort a,clientsrecord b where a.orig_clli=b.orig_clli and a.date='" + TextBox1.Text + "' and b.emplye='Ankit'", con1);
      con1.Open();
      OdbcDataAdapter da = new OdbcDataAdapter(cmd);
      da.Fill(ds);

      con1.Close();
      GridView17.DataSource = ds;
      GridView17.DataBind();
      //GridView17.DataSourceID = String.Empty;
      mdlPopup.Show();
      //Label2.Text = "Details of Ankit on " + " " + TextBox1.Text;
  }


  public void Customer_Click(object sender, EventArgs e)
  {
     // modalPopUpExtender1.Hide();
      //string QueryString= TextBox1.Text;
      //Page.ClientScript.RegisterStartupScript(GetType(), "", "window.open('Default2.aspx?QS=" + QueryString + "','','width=500,height=500');"", true);

      //DataSet dspop = new DataSet();
      LinkButton Lnk = (LinkButton)sender;
      //Label2.Text = Lnk.Text;
      TextBox5.Text = Lnk.Text;
      //TextBox3.Text = Lnk.Text;
      OdbcConnection con1 = new OdbcConnection(ConfigurationManager.ConnectionStrings["connect4"].ConnectionString);
      OdbcCommand cmd = new OdbcCommand("select orig_clli as Origclli  from welco_all.clientsrecord  where  customer='" + TextBox5.Text + "' ", con1);
      con1.Open();
      OdbcDataAdapter da = new OdbcDataAdapter(cmd);
      DataSet dscust = new DataSet();

      using (OdbcDataReader read = cmd.ExecuteReader())
      {
          while (read.Read())
          {
              TextBox6.Text = (read["Origclli"].ToString());
              //TextBox6.Text = (read["password"].ToString());



          }
          read.Close();

      }
      con1.Close();


      string date = TextBox1.Text.Replace("-","_");
      OdbcConnection con = new OdbcConnection(ConfigurationManager.ConnectionStrings["connect3"].ConnectionString);
      OdbcCommand cmd2 = new OdbcCommand("SELECT a.orig_clli, b.clli_name as Vendor,  a.region as Region, round(sum(a.billedSeconds/60),2) as MIns, round(sum(a.amount),4) as Amount, round(sum(a.v_billedSeconds/60),2) as V_Mins, round(sum(a.v_amount),4) as V_Amount,round(sum(a.amount)-sum(a.v_amount),2) as profit from  welco1_all.az_outbound_cdr_" + date + " a,welco1_all.outbound_vendor_master b where orig_clli in('" + TextBox6.Text + "') and a.term_clli=b.clli GROUP BY a.term_clli, a.orig_clli, a.region ORDER BY a.term_clli, a.orig_clli, a.region", con);

      //SELECT a.orig_clli, b.clli_name as Vendor,  a.region as Region, round(sum(a.billedSeconds/60),2) as MIns, round(sum(a.amount),4) as Amount, round(sum(a.v_billedSeconds/60),2) as V_Mins, round(sum(a.v_amount),4) as V_Amount,round(sum(a.amount)-sum(a.v_amount),2) as profit from  welco1_all.az_outbound_cdr_"+date+" a,welco1_all.outbound_vendor_master b where orig_clli in('" + TextBox6.Text + "') and a.term_clli=b.clli GROUP BY a.term_clli, a.orig_clli, a.region ORDER BY a.term_clli, a.orig_clli, a.region
      //try
      //{
          con.Open();
          OdbcDataAdapter da2 = new OdbcDataAdapter(cmd2);
          da2.Fill(dsnewpop1);
          con.Close();
          GridView34.DataSource = dsnewpop1;
          GridView34.DataBind();


          mdlChild.Show();
      //}
      //catch (Exception er)
      //{

      //    throw (er);
      //}



      //Label20.Text = "Details of Umesh on " + " " + TextBox1.Text;



  }
Posted
Updated 31-Aug-16 1:08am
v4
Comments
Herman<T>.Instance 30-Aug-16 6:46am    
NO SHOUTING PLEASE
mridulkoul123 30-Aug-16 7:39am    
u have any advice on this???
Herman<T>.Instance 30-Aug-16 10:49am    
DONT USE CAPITALS ALONE

 
Share this answer
 
Comments
mridulkoul123 31-Aug-16 1:40am    
I tried almost every format of connection srings but nothing good come out yet.
Andy Lanng 31-Aug-16 4:01am    
oh >_<
Well the error does state "Access denied". That would imply to me that the account details are wrong. Is that possible?
mridulkoul123 31-Aug-16 4:51am    
no...the same details are working in other projects...i am so badly struck
Andy Lanng 31-Aug-16 4:54am    
I had an issue recently where our mysql server was refusing connections because it had hit an upper limit. We solved the long term issue by stopping some unused indexing scheduled tasks and restarting the sql db to fix the short term upper limit issue. Could that help?
mridulkoul123 31-Aug-16 5:02am    
server is making connection when i use some other query from the same database ... but not executing this query...but the same query is executing in mysql query browser... what does that mean?
I'm gonna be pretty anal about this, but your code is very vulnerable. MySQL really doesn't like un-disposed connections.

Please change your code as follows:
C#
//Move your query to a const strin.  This is just good practice
        private const string Query =@"SELECT 
    a.orig_clli, 
    b.clli_name as Vendor, 
    a.region as Region, 
    round(sum(a.billedSeconds/60),2) as MIns, 
    round(sum(a.amount),4) as Amount, 
    round(sum(a.v_billedSeconds/60),2) as V_Mins, 
    round(sum(a.v_amount),4) as V_Amount, 
    round(sum(a.amount)-sum(a.v_amount),2) as profit 
from 
    welco1_all.az_outbound_cdr_{0} a 
    inner join welco1_all.outbound_vendor_master b on a.term_clli=b.clli 
where 
    orig_clli in(@clli) 
GROUP BY 
    a.term_clli, 
    a.orig_clli, 
    a.region 
ORDER BY 
    a.term_clli, 
    a.orig_clli, 
    a.region";
//The @ makes the string literal so you can format the query nicely.  This really helps readability.  The {0} in there will be replaced in a string.Format. 

It's regrettable that your db is build this way as it still leaves your code open to attack.

What if someone entered the following into textBox6:
";SELECT host, user, password FROM mysql.user; #"
It's trivial to change the input type on a webform from date to text

There are ways to prevent this:
How To: Protect From SQL Injection in ASP.NET[^]

anyway - On with the code...
C#
//The "using" syntax releases and disposes of the command and connection.
            using (OdbcConnection con =
                    new OdbcConnection(ConfigurationManager.ConnectionStrings["connect3"].ConnectionString))
            {
                using (OdbcCommand cmd2 = con.CreateCommand())
                {
                    //replace the {0} with date
                    cmd2.CommandText = string.Format(Query,date);
                    //add the parameter.  This is the injection safe way
                    cmd2.Parameters.AddWithValue("@clli", TextBox6.Text);
                    cmd2.CommandType = CommandType.Text;
                    cmd2.CommandTimeout = 600;
                    con.Open();
                    using (OdbcDataAdapter da2 = new OdbcDataAdapter(cmd2))
                    {
                        da2.Fill(dsnewpop1);
                    }
                        con.Close();
                }
            }
            // as soon as the using parenthesis is closed the object is disposed of
            GridView34.DataSource = dsnewpop1;
            GridView34.DataBind();
            mdlChild.Show();
 
Share this answer
 
Comments
mridulkoul123 31-Aug-16 7:45am    
brother still no hit...

Cannot set CommandTimeout to longer than 90 seconds...its bydefault taking 90 sec...dont know why?
Andy Lanng 31-Aug-16 8:10am    
I'm seeing some hints that might imply that odbc timeout isn't supported in some versions of mysql.
Try setting it in the connection string:
string conString = ConfigurationManager.ConnectionStrings["connect3"].ConnectionString + "READTIMEOUT=300;";
(assuming the connection string has a semicolon ';' at the end (which it should)
mridulkoul123 31-Aug-16 8:18am    
I tried this also...still no advancement...:(
Andy Lanng 31-Aug-16 8:27am    
GRRR.
Fine. We'll show him (him being your sql db)
run this on your db:
SET GLOBAL connect_timeout=600;

That will change the connection timeout on the server side. Be warned: This 'could' cause undesired effects if your system is prone to timeouts
mridulkoul123 31-Aug-16 8:36am    
Nothing brother ...here are the traces from the browser... it is don't know why somehow fixed to 90...shown in chrome traces below

POST XHR http://localhost:20414/Summary_Profit_Loss_try/Default3.aspx : in firefox

POST http://localhost:20414/Summary_Profit_Loss_try/Default3.aspx 90001ms : in chrome

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