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 7779219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:35:42+00:00 2026-06-01T18:35:42+00:00

I am using C#(asp.net). I have two tables(data and details) in a same database.

  • 0

I am using C#(asp.net). I have two tables(data and details) in a same database.

Table “data”

id | chap | unit |
  ----------------
  1| chap1|unit1 |
  2| chap2|unit2 |
  3| chap3|unit3 |

Table “details”

id| code| num |
----------------
 1|abc  |2    |
 2|efg  |3    |
 3|hij  |1    |

Now I want to fetch a value from “num” where code=”efg” (in table “details”). And use the same value (3) to fetch data from table “data” by id. I am using this code.

OleDbConnection conn = new OleDbConnection(*** ...... *****); 
       OleDbCommand cmd;
       OleDbDataReader reader;
        String query = String.Format("select num from details where code="efg");
        cmd = new OleDbCommand(query, conn);
        reader = cmd.ExecuteReader();
        int num = int.Parse(reader.GetValue(0).ToString());

        query = String.Format("select chap from data where id={0}",num);
         cmd = new OleDbCommand("select lesson from data where id=3", conn);
        reader = cmd.ExecuteReader();


        Label1.Text = reader.GetValue(0).ToString();

But it shows error. It shows “No data exists for the row/column.”

  • 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-06-01T18:35:43+00:00Added an answer on June 1, 2026 at 6:35 pm

    You can use

    SELECT d.chap, d.unit
    FROM data d INNER JOIN details de
        ON d.id = de.num
    WHERE de.code = 'efg'
    

    or

    SELECT d.chap, d.unit
    FROM data d INNER JOIN details de
        ON d.id = de.num
       AND de.code = 'efg'
    

    More: if you’re using SQL-Server, use SqlConnection in place of OleDbConnection.
    More: don’t format your query joining strings, numbers, dates and so on; use SqlParameter so you don’t have to worry about types and formatting!!

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

Sidebar

Related Questions

ASP.NET 3.5 C# I am joining two tables using Linq. Table names are MapAssets
I am using ASP.NET Dynamic Data for a project and I have a table
I am using Asp.net dropdownlist in one of my form ..I have two dropdown
I have one asp.net web application. It is using two membership provider. Two sign-in
I'm using ASP.NET and I have a string of HTML in the database. I
I had created a webpage using asp.net mvc3 razor. I have two master pages
I have two tables in my database: Company table (ID, CompanyName, CompanyUsername, CompanyPassword) Employee
I have two tables in my database as following: Employee Table: Username, Name, Job,
sending mail along with embedded image using asp.net I have already used following but
I'm using asp.net/c# and have a number of Collapsible Panel Extenders that have been

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.