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

  • Home
  • SEARCH
  • 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 6044649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:02:08+00:00 2026-05-23T07:02:08+00:00

I have two columns syntax and query in my table Table1 . Syntax contains

  • 0

I have two columns syntax and query in my table Table1. Syntax contains data called po and a query called select * from po_pomas_pur_order_hdr where pomas_pono =. I got this query value by using

SqlDataAdapter da = new SqlDataAdapter("select query from Table1 where syntax = '" + textBox1.Text + "'", conn);

And my problem is that I need to dynamically pass another value inside the query which I retrived using dataadapter like this:

 SqlDataAdapter da1 = new SqlDataAdapter(da.tostring()  +"'"+ textBox1.Text +"'", conn)

The resulting query should be like this:

 select * from po_pomas_pur_order_hdr where pomas_pono = '2PO/000002/09-10'

But it is not possible. How to get a query like this? Any suggestion?

  • 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-23T07:02:09+00:00Added an answer on May 23, 2026 at 7:02 am

    SqlDataAdapter is used to fill datasets and datatables. You cannot obtain the result of a query with ToString(). I think you want to use SqlCommand to execute your first query to retrieve the actual query to run from the database like this:

    string query = null;
    using (var command = new SqlCommand("select query from Table1 where syntax = @Syntax", conn))
    {
        command.Parameters.AddWithValue("@Syntax", textBox1.Text);
        query = command.ExecuteScalar(); // this assumes only one query result is returned
    }
    

    Then you can use the data adapter to fill it:

    SqlDataAdapter da1 = new SqlDataAdapter(query  +"'"+ textBox1.Text +"'", conn);
    

    Although I would suggest to use parameters for that as well.

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

Sidebar

Related Questions

I have the following two columns: SELECT b.ip_address AS IP ,b.mask AS MASK FROM
I have a table called Foo and I have two columns: Lorem and Ipsum,
I have two tables with the following columns: table1: id, agent_name, ticket_id, category, date_logged
I have two tables in my database: NEWS table with columns: id - the
I have a table y Which has two columns a and b Entries are:
I have a simple table made up of two columns: col_A and col_B .
I have two columns in my ForumPost Table: Id and ThreadId . I want
I have 3 tables on which i need to select data from using ms-access
I have two tables suppose table 1 has two columns with short names and
i have a table called propAmenities which holds two column amenity_id and property_id basically

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.