Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 282257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:16:24+00:00 2026-05-12T05:16:24+00:00

I have a weird problem. My query in C#/ASP.NET returns results 5 times. I

  • 0

I have a weird problem. My query in C#/ASP.NET returns results 5 times. I tried brakepoint-ing but I can’t find the error. I have 2 related tables. One table loads on PAGE_LOAD and when the user click on a cell, it shows the content from another table related to that cell. It’s very simple.

    //PAGE LOAD
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbpath + "/secure_user/data/data.mdb");
        OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT Project,Manager,Customer,Deadline FROM projects WHERE Username='" + uname + "'", myConnection);
        DataTable table = new DataTable();
        adapter.Fill(table);
        adapter.Dispose();
        GridView1.DataSource = table;
        GridView1.DataBind();
    }
}

It loads projects table to the GridView. Now when I click a certain project, it displays more information about that project:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    GridViewRow row = GridView1.SelectedRow;
    Label1.Text = row.Cells[1].Text;
    OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbpath + "/secure_user/data/data.mdb");
    OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT tasks.Task,tasks.Priority,tasks.Done,taska.Hours FROM projects,tasks WHERE tasks.Username='" + uname + "' AND tasks.Project='" + Label1.Text + "'", myConnection);
    DataTable table = new DataTable();
    adapter.Fill(table);
    adapter.Dispose();
    GridView2.DataSource = table;
    GridView2.DataBind();
    GridView2.Visible = true;
}

It displays with no error, but it does 5 times no matter what project I select from GridView1, it always displays GridView2 (second table) content 5 times in a row. What could be the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:16:25+00:00Added an answer on May 12, 2026 at 5:16 am

    Looks like you have something wrong in your query. Try using INNER JOIN instead of ,.

    Instead of this:

    SELECT tasks.Task, tasks.Priority, tasks.Done, tasks.Hours
    FROM projects, tasks
    WHERE tasks.Username='" + uname + "' AND tasks.Project='" + Label1.Text + "'
    

    Try this:

    SELECT tasks.Task, tasks.Priority, tasks.Done, tasks.Hours
    FROM projects INNER JOIN tasks ON projects.ID = tasks.ProjectID --> may not be correct depends on your table structure
    WHERE tasks.Username='" + uname + "' AND tasks.Project='" + Label1.Text + "'
    

    Another thing: building a SQL query like that is prone to SQL Injection attack.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird problem with my mysql query syntax. I have made a
I have a weird problem. When I execute a query the data is not
I have a weird problem. I create this window, but its blank until i
I have a weird problem that i can't figure out a solution for: I've
I have a paged ASP.NET ListView. The data shown is filtered, which can be
Very weird problem. Saving email addresses to my database, but when I query those
I have a weird problem with my sql script. I have a string $query
I have a very weird problem while trying to pass and SQL query using
I have run into a rather weird problem. I have created the following query
I have run a weird problem. Maybe someone here can help me. My SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.