Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Combining 2 sql statements using Ole and not Sql

Combining 2 sql statements using Ole and not Sql

Scheduled Pinned Locked Moved ASP.NET
databasecsharpasp-netsql-servercom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi, I have 2 sql statements which will run in Access: private string m_cmdInitial = "Select Distinct Mid([Attribute Name],1,1) AS Initial FROM [Attributes]"; private string m_cmdCustmrs = "SELECT * FROM [Attributes] WHERE(Attributes.[Attribute Name]) LIKE '{0}*'"; The thing is that using SQL server the two sql statements can be combined using the format Function of ASP.net just by putting semicolon between the statements. The purpose is as follows: I am using 2 data lists. The first one is just a list of letters on top from which the user can choose a letter on which the term starts. The second data list shows the results(Customers datalist). So the first sql statement is an argument for the second sql(the Like '{0}*' statement. Does anyone know how to do this using access version and not sql server? Thank you. Here is a code where the sql statements will be used: private void BindData(string initial) { OleDbConnection conPubs = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("DB//DataDictionary.mdb")) ; // Store the initial ViewState["Initial"] = initial; // string _cmdText = m_cmdInitial; // string _cmdTextSecond = m_cmdCustmrs; string _cmdText = m_cmdInitial +";"; _cmdText += String.Format(m_cmdCustmrs, initial); // _cmdText += ";"; OleDbDataAdapter _adapter = new OleDbDataAdapter(_cmdText, conPubs); DataSet _data = new DataSet(); _adapter.Fill(_data,"Attributes"); // Rename tables _data.Tables[0].TableName = "Initials"; // _data.Tables[1].TableName = "Attributes"; // Reset selected and edit items Customers.SelectedIndex = -1; Customers.EditItemIndex = -1; Picker.DataSource = _data.Tables["Initials"].DefaultView; Picker.DataBind(); Customers.DataSource = _data.Tables["Initials"].DefaultView; Customers.DataBind(); conPubs.Close(); }

    J 1 Reply Last reply
    0
    • A Anonymous

      Hi, I have 2 sql statements which will run in Access: private string m_cmdInitial = "Select Distinct Mid([Attribute Name],1,1) AS Initial FROM [Attributes]"; private string m_cmdCustmrs = "SELECT * FROM [Attributes] WHERE(Attributes.[Attribute Name]) LIKE '{0}*'"; The thing is that using SQL server the two sql statements can be combined using the format Function of ASP.net just by putting semicolon between the statements. The purpose is as follows: I am using 2 data lists. The first one is just a list of letters on top from which the user can choose a letter on which the term starts. The second data list shows the results(Customers datalist). So the first sql statement is an argument for the second sql(the Like '{0}*' statement. Does anyone know how to do this using access version and not sql server? Thank you. Here is a code where the sql statements will be used: private void BindData(string initial) { OleDbConnection conPubs = new OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("DB//DataDictionary.mdb")) ; // Store the initial ViewState["Initial"] = initial; // string _cmdText = m_cmdInitial; // string _cmdTextSecond = m_cmdCustmrs; string _cmdText = m_cmdInitial +";"; _cmdText += String.Format(m_cmdCustmrs, initial); // _cmdText += ";"; OleDbDataAdapter _adapter = new OleDbDataAdapter(_cmdText, conPubs); DataSet _data = new DataSet(); _adapter.Fill(_data,"Attributes"); // Rename tables _data.Tables[0].TableName = "Initials"; // _data.Tables[1].TableName = "Attributes"; // Reset selected and edit items Customers.SelectedIndex = -1; Customers.EditItemIndex = -1; Picker.DataSource = _data.Tables["Initials"].DefaultView; Picker.DataBind(); Customers.DataSource = _data.Tables["Initials"].DefaultView; Customers.DataBind(); conPubs.Close(); }

      J Offline
      J Offline
      Javier Lozano
      wrote on last edited by
      #2

      First of all, use parameterized queries rather than string concatenation. Second, why are you trying to execute these at the same time? ~Javier Lozano

      A 1 Reply Last reply
      0
      • J Javier Lozano

        First of all, use parameterized queries rather than string concatenation. Second, why are you trying to execute these at the same time? ~Javier Lozano

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        Can you show me an example using my code?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups