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. problem with a query

problem with a query

Scheduled Pinned Locked Moved ASP.NET
helpdatabaseworkspace
6 Posts 4 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.
  • B Offline
    B Offline
    brunkovac29
    wrote on last edited by
    #1

    ok, so i'm trying to make a search page with listings of the results. here's the method: private bool Search( String strSearchString ) { bool ok = false; OleDbConnection connSearch = new OleDbConnection( System.Configuration.ConfigurationSettings.AppSettings[ "connString" ] ); OleDbCommand cmdSearchOpis = new OleDbCommand(); Common.NapuniCommand( cmdSearchOpis, "proc_Search", connSearch ); Common.NapraviParametar( cmdSearchOpis, "@SearchString", OleDbType.VarChar, strSearchString, "Input" ); try { connSearch.Open(); OleDbDataAdapter da = new OleDbDataAdapter( cmdSearchOpis ); DataTable dt = new DataTable(); da.Fill( dt ); if( dt.Rows.Count == 0 ) ok = false; else { rptSearchResultsTvrtke.DataSource = dt; rptSearchResultsTvrtke.DataBind(); ok = true; } da.Dispose(); dt.Dispose(); cmdSearchOpis.Dispose(); } catch( Exception ex ) { lblError.Text = ex.Message; } finally { connSearch.Close(); connSearch.Dispose(); } return ok; } so, when i use the following query ( with let's say, strSearchString = "a" ): SELECT * FROM tKorisnici WHERE Opis LIKE ("*" & [@SearchString] & "*") AND User=true; i get no results ( dt.Rows.Count = 0 ) Although when i run the query in Access 2002, i do get results. any other query with or without parameters works just fine and fills the repeater (rptSearchResultsTvrtke), and i'm pretty much stuck in here. plz help! :confused:

    D M 2 Replies Last reply
    0
    • B brunkovac29

      ok, so i'm trying to make a search page with listings of the results. here's the method: private bool Search( String strSearchString ) { bool ok = false; OleDbConnection connSearch = new OleDbConnection( System.Configuration.ConfigurationSettings.AppSettings[ "connString" ] ); OleDbCommand cmdSearchOpis = new OleDbCommand(); Common.NapuniCommand( cmdSearchOpis, "proc_Search", connSearch ); Common.NapraviParametar( cmdSearchOpis, "@SearchString", OleDbType.VarChar, strSearchString, "Input" ); try { connSearch.Open(); OleDbDataAdapter da = new OleDbDataAdapter( cmdSearchOpis ); DataTable dt = new DataTable(); da.Fill( dt ); if( dt.Rows.Count == 0 ) ok = false; else { rptSearchResultsTvrtke.DataSource = dt; rptSearchResultsTvrtke.DataBind(); ok = true; } da.Dispose(); dt.Dispose(); cmdSearchOpis.Dispose(); } catch( Exception ex ) { lblError.Text = ex.Message; } finally { connSearch.Close(); connSearch.Dispose(); } return ok; } so, when i use the following query ( with let's say, strSearchString = "a" ): SELECT * FROM tKorisnici WHERE Opis LIKE ("*" & [@SearchString] & "*") AND User=true; i get no results ( dt.Rows.Count = 0 ) Although when i run the query in Access 2002, i do get results. any other query with or without parameters works just fine and fills the repeater (rptSearchResultsTvrtke), and i'm pretty much stuck in here. plz help! :confused:

      D Offline
      D Offline
      Daniel Santillanes
      wrote on last edited by
      #2

      Have you tried using "%" instead of "*"? That's how it works on MS SQL Server, and I'm assuming you are using... Access 2003? try it. daniero

      B 1 Reply Last reply
      0
      • D Daniel Santillanes

        Have you tried using "%" instead of "*"? That's how it works on MS SQL Server, and I'm assuming you are using... Access 2003? try it. daniero

        B Offline
        B Offline
        brunkovac29
        wrote on last edited by
        #3

        alright daniero, that was my problem... funny thing is that if i put % and run it in Access it gives a blank table. if i try to execute it through the code, i DO GET RESULTS!!! now, with * instead of % if i run it in Access i get results, but not through code... that's really odd if you ask me, but i'm glad u helped me solve this problem. thank you daniero, my savior of the day! :)

        I D 2 Replies Last reply
        0
        • B brunkovac29

          alright daniero, that was my problem... funny thing is that if i put % and run it in Access it gives a blank table. if i try to execute it through the code, i DO GET RESULTS!!! now, with * instead of % if i run it in Access i get results, but not through code... that's really odd if you ask me, but i'm glad u helped me solve this problem. thank you daniero, my savior of the day! :)

          I Offline
          I Offline
          Ista
          wrote on last edited by
          #4

          Access is odd 1 line of code equals many bugs. So don't write any!!

          1 Reply Last reply
          0
          • B brunkovac29

            ok, so i'm trying to make a search page with listings of the results. here's the method: private bool Search( String strSearchString ) { bool ok = false; OleDbConnection connSearch = new OleDbConnection( System.Configuration.ConfigurationSettings.AppSettings[ "connString" ] ); OleDbCommand cmdSearchOpis = new OleDbCommand(); Common.NapuniCommand( cmdSearchOpis, "proc_Search", connSearch ); Common.NapraviParametar( cmdSearchOpis, "@SearchString", OleDbType.VarChar, strSearchString, "Input" ); try { connSearch.Open(); OleDbDataAdapter da = new OleDbDataAdapter( cmdSearchOpis ); DataTable dt = new DataTable(); da.Fill( dt ); if( dt.Rows.Count == 0 ) ok = false; else { rptSearchResultsTvrtke.DataSource = dt; rptSearchResultsTvrtke.DataBind(); ok = true; } da.Dispose(); dt.Dispose(); cmdSearchOpis.Dispose(); } catch( Exception ex ) { lblError.Text = ex.Message; } finally { connSearch.Close(); connSearch.Dispose(); } return ok; } so, when i use the following query ( with let's say, strSearchString = "a" ): SELECT * FROM tKorisnici WHERE Opis LIKE ("*" & [@SearchString] & "*") AND User=true; i get no results ( dt.Rows.Count = 0 ) Although when i run the query in Access 2002, i do get results. any other query with or without parameters works just fine and fills the repeater (rptSearchResultsTvrtke), and i'm pretty much stuck in here. plz help! :confused:

            M Offline
            M Offline
            mr_debasishdas
            wrote on last edited by
            #5

            Hi, Can u do one thing, before putting the query in to your .cs file check that query executes well with MS SQL server instead of Access because i am bit scared that you are using "*", correct your query according to MSSQLserver query analyser. Then Try. :) DD Debasish Das(MBA), is a hardcore software solution provider, working in ESSPL (INDIA). Got 5 years of experience on various client server technologies like Visual Basic,.NET framework, Power Builder, Message Queue Server. And also posses sound knowledge in Quality Processes applied to software engineering. Quite often travels overseas to provide solutions to some fortune 100 clients. He can be reached with mr_debasishdas@hotmail.com or debasishd@esspl.com

            1 Reply Last reply
            0
            • B brunkovac29

              alright daniero, that was my problem... funny thing is that if i put % and run it in Access it gives a blank table. if i try to execute it through the code, i DO GET RESULTS!!! now, with * instead of % if i run it in Access i get results, but not through code... that's really odd if you ask me, but i'm glad u helped me solve this problem. thank you daniero, my savior of the day! :)

              D Offline
              D Offline
              Daniel Santillanes
              wrote on last edited by
              #6

              I'm glad you've got it working :) daniero

              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