Hibernate doubt when make search

Hello,
yesterday I have got this problem:
I have my java app that use Hibernate (3.0) for make search on DB (MySQl 5.0).
If I sent a search method (with hibernate method "session.createCriteria"), sometimes it worked good, and sometime it gives me this error:
org.hibernate.MappingException: Could not read mappings from resource: basket.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at it.eminds.data.Basket.searchBasketInfo(Basket.java:406)
at it.eminds.ws.basket.Basket.BasketWs.OTA_SearchBasketRQ(BasketWs.java:8926)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:388)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:283)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:834)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingException: Could not parse mapping document in input stream
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:431)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 36 more
Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:422)
I don't understand why I have this error "Could not read mappings from resource: basket.hbm.xml" if sometimes it works!.
Can you please helpme to understand the problem (or cause)?? It's very URGENT!!
Thanks,
Francesco
These are my hibernate xml file:
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.sybase.jdbc3.jdbc.SybDriver</property>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/lmt</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.SybaseDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- Mapping files -->
<mapping resource="basket.hbm.xml"/>
</session-factory>
</hibernate-configuration>
basket.hbm.xml :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
     "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
     "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
     <!-- it.eminds.data.Basket root -->
     <class name="it.eminds.data.Basket" table="Basket">
          <composite-id>
               <key-property name="id" column="id" />
               <key-property name="bookID" column="bookID"/>
          </composite-id>     
          <property name="utente" type="string" >
               <column name="utente" not-null="false" sql-type="text"/>
          </property>
          <property name="carteDiCredito" type="string" >
               <column name="carteDiCredito" not-null="false" sql-type="text"/>
          </property>
          <property name="cliente" type="string" >
               <column name="cliente" not-null="false" sql-type="text"/>
          </property>
          <property name="spedizione" type="string" >
               <column name="spedizione" not-null="false" sql-type="text"/>
          </property>
          <!--<property name="bookID" column="bookID" type="string" length="16"/>-->
          <property name="dataBooking" column="dataBooking" type="timestamp"/>
          <property name="bookId_Gest" column="bookId_Gest" type="string" length="16"/>
          <property name="pos" type="string" >
               <column name="pos" not-null="false" sql-type="text"/>
          </property>
          <!-- tabella Array servizi type="boolean" -->
          <bag name="servizi" cascade="all">
<key>
     <column name="uid" />
     <column name="ubookID" />
</key>
<one-to-many class="it.eminds.data.ServiceBasket"/>
</bag>
     </class>
<class name="it.eminds.data.ServiceBasket" table="serviceBasket">
          <id name="id" unsaved-value="0">
<generator class="increment"/>
</id>
     <property name="pax" type="string" >
     <column name="pax" not-null="false" sql-type="text"/>
     </property>
     <property name="RQBook" type="string" >
          <column name="RQBook" not-null="false" sql-type="text"/>
     </property>      
     <property name="RSBook" type="string">
          <column name="RSBook" not-null="false" sql-type="text"/>
     </property>
     <property name="RSPrev" type="string">
          <column name="RSPrev" not-null="false" sql-type="text"/>
     </property>
     <property name="Type" column="Type" type="integer"/>
               <property name="idServizio" column="idServizio" type="integer"/>
               <property name="failed" column="failed" type="string" length="12" />
               <property name="invoiceNumber" column="invoiceNumber" type="string" length="12" />
               <property name="notaNumber" column="notaNumber" type="string" length="12" />
               <property name="startDate" column="startDate" type="timestamp"/>
               <property name="correlation" column="correlation" type="string" length="10" />
</class>
</hibernate-mapping>

Hi,
you can override the query listener on the af:query component and if your complex condition is not met, show an error message (either you show an FacesMessage message or open a popup dialog) and don't execute the query
See:
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/85-querycomponent-fieldvalidation-427197.pdf
and
"http://www.oracle.com/technetwork/developer-tools/adf/learnmore/85-querycomponent-fieldvalidation-427197.pdf" (page 15) http://www.oracle.com/technetwork/developer-tools/adf/learnmore/85-querycomponent-fieldvalidation-427197.pdf
The latter document is needed as af:query supports switching view criterias (and thus searches) in which case your field dependencies may change
Frank

Similar Messages

  • I can't find folder when I make Search with new OS X Mavericks update?

    1- I can't find folder when I make Search with new OS X Mavericks update? I have 4 Tr HD when am looking for my file I have to make search but now search can't find files?????
    2- alt is not working?

    Hello,
    I use to do search like this before I update my Mac, how I can do it now?

  • I upload a podcast each week using Podcast Maker. When I search the iTunes Store to determine if the most recent one is listed all the podcasts are in random order. This week's is

    I upload a podcast each week using Podcast Maker. When I search the iTunes Store to determine if the most recent one is listed all the podcasts are in random order. This week's is #14; last week's is #1. Any ideas how to correct this? The odd thing is that when you try to subscribe to the podcasts, they are listed in the proper order.

    Many thanks.
    With those symptoms, I'd try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

  • If I have a pic in more than one album, does iPhoto make more than one copy of that pic?  When I search the file name on finder, it seems to be showing one copy of that file for every album it's in.

    If I have a pic in more than one album, does iPhoto make more than one copy of that pic?  When I search the file name on finder, it seems to be showing one copy of that file for every album it's in.

    No it doesn't. Albums simply reference the photos in the Library. A single shot can be in 100 albus and use no extra disk space at all.
    If you have the same shot in two Events then yes, the file is duplicated.
    When I search the file name on finder, it seems to be showing one copy of that file for every album it's in.
    The Finder doesn't really understand the iPhoto Library. It's quite possible for the iPhoto Library to contain many files with the same name. The Library also contains different versions of the same shot - thumbnail, originals and edited version. This is normal.
    Regards
    TD

  • How do I get bing off my mac. Safari keeps defaulting to Bing when I search. Thank you. Peter Morse

    How do I get bing off my Mac. Safari keeps defaulting to Bing when I search. Thank you.

    You installed the "Genieo" search-hijacking rootkit. There is an uninstaller, but as the developer is dishonest, you can't use it. I suggest the tedious procedure below to disable Genieo.
    Back up all data. You must know how to restore from a backup even if the system becomes unbootable. If you don't know how to do that, or if you don't have any backups, stop here and ask for guidance.
    Step 1
    Triple-click anywhere in the line below on this page to select it:
    /etc/launchd.conf
    Right-click or control-click the line and select
    Services ▹ Reveal in Finder (or just Reveal)
    from the contextual menu.
    If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.
    A folder may open with a file selected, or the file may not exist, in which case you'll get a message that it can't be found. If it does exist, it's a configuration file created or replaced by the Genieo installer. Any software installer that does this should be considered ipso facto malware. Move the file to the Trash. You'll be prompted for your administrator password. Then restart, empty the Trash, and continue as below.
    IMPORTANT: If the launchd.conf file exists, you must move it to the Trash and restart before continuing. Otherwise the system may become unbootable. In that case, restore from your backup and start over. That's how badly Genieo has sabotaged your system. If you're not completely sure you can complete this step, stop here and ask for guidance.
    Some variants of Genieo don't include the launchd.conf file. The absence of that file doesn't mean that Genieo is not installed.
    Step 2
    Quit the Genieo application, if it's running. Force quit if necessary.
    Move each of these items to the Trash in the same way as above:
    /Applications/Genieo.app
    /Applications/Uninstall Genieo.app
    /Library/Frameworks/GenieoExtra.framework
    /Library/LaunchAgents/com.genieo.engine.plist
    /Library/LaunchAgents/com.genieoinnovation.macextension.plist
    /Library/LaunchDaemons/com.genieoinnovation.macextension.client.plist
    /Library/PrivilegedHelperTools/com.genieoinnovation.macextension.client
    /usr/lib/libgenkit.dylib/usr/lib/libgenkitsa.dylib
    /usr/lib/libimckit.dylib
    /usr/lib/libimckitsa.dylib
    There's no need to restart after each one. Again, some of these items may be absent, in which case you'll get a message that the file can't be found. Skip that item and go on to the next one.
    Restart and empty the Trash. Don't try to empty the Trash until you have restarted.
    Your web browser(s) should now function normally, and you should be able to reset the home page and search engine. If not, stop here and post your results.
    Step 3
    From the Safari menu bar, select
    Safari ▹ Preferences... ▹ Extensions
    Uninstall any extensions you don't know you need, including ones called "Genieo" or "Omnibar," and any that have the word "Spigot" or "InstallMac" in the description. If in doubt, uninstall all extensions. Do the equivalent for the Firefox and Chrome browsers, if you use either of those.
    This procedure may leave a few files behind, but it should deactivate Genieo. Make sure you don't repeat the mistake that led you to install it. Chances are you got it from one of the Internet's open sewers such as "Softonic" or "CNET Download." Never visit either of those sites again. You might also have downloaded it from an ad in a page on some other site.
    Finally, be forewarned that when Genieo is mentioned on this site, the developer sometimes shows up under the name "Genieo support." If that happens, don't believe anything he says, but feel free to tell him what you think of his scam.

  • When I search for videos in google, it takes me to the different website after clicking the search

    I installed FF 4 and I was happy with the look and feel and performance untill oneday I tried to google some vedios.
    When I click on the search results which most of the time suggests to be youtube link, it takes me to altogether different website which I never heard of. I expect when the search result shows me source as youtube, I should be able to go to youtube on clicking on the results.

    1. You need to use Firefox at the Adobe website to get the NPAPI version of Flash for non-IE browsers.
    Download the Flash plugin from the Adobe [http://get.adobe.com/flashplayer/thankyou/ Thank You!] page via:
    '''If it does not start, [http://www.adobe.com/go/fptroubleshoot click here] for troubleshooting information.'''
    On the [http://www.adobe.com/products/flashplayer/support/index.html troubleshooting page] click the link at the bottom:
    If you are still having problems, [http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player_ax.exe click here to download].
    Save it to your Desktop.
    2. Close Firefox using File > Exit
    then check the Task Manager > Processes tab to make sure '''firefox.exe''' is closed,
    3. Then run the Flash setup file from your Desktop.
    * On Vista and Windows 7 you may need to run the plugin installer as Administrator by starting the installer via the right-click context menu if you do not get an UAC prompt to ask for permission to continue (i.e nothing seems to happen).
    See this:
    [http://vistasupport.mvps.org/run_as_administrator.htm]
    You also need to update Java - Firefox 3.6+ version need 1.6.0_10 or higher, for the Next Generation plugin.
    http://www.java.com/en/download/index.jsp

  • When I search a music artist in the itunes store and then click to view all albums the screen is blank.

    When I search a music artist in the itunes store and then click to view all albums the screen is blank. Why is itunes store not showing me all of the Albums?

    This can be a problem with the file places.sqlite that stores the bookmarks and the history.
    * http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    Make sure that you not run Firefox in (permanent) [[Private Browsing]] mode

  • I bough a refurbished iMac last year, unfortunately Im in need of a Logic board, but when I search FD093LL/A, no company seems to recognize this model but I do see all models, or at least most, starting with MD...whats the difference?

    I bought a refurbished iMac last year, unfortunately I'm in need of a new/used Logic board, but when I search and contact Company with Mac parts, no one seems to recognize FD093LL/A witch makes it tough to identify parts, but I do see most Part Numbers starting with MD. Any reason why?
    Thank you

    Refurbished models have a different order number. Replace the F with an M and see if the specifications listed match your computer’s.
    (115253)

  • My search media bar brings up the stuff I want when I search for it but won't let me click on the results for anything.

    Hi guys, I've been having troubles with my search bar for searching media in itunes. It worked a while ago but now when I search it brings up results and the results I want but it won't let me click them for anything. I can't go to the song, album or artist or add it to the song queue. It's really annoying to go through my library and search for a specific song without using the search. Please Help!
    Thank You!

    you said you turned your phone off. was it a reboot, or an off? Ive noticed that if the memory is low and you have
    a lot of apps or processes running, it really causes the system lag. Try holding down the top button and home button at the same time. Then wait until it has powered down. In 60 sec or so, restart it the same way. Should fix your issue. There is an app I use called Lite Scan. It allows me to see what is running and it will free up 30mg at a time. Not much granted but enuf to keep the system from going to a crawl.
    as far as your device in itunes goes, open itunes, without your phone connected. look in the advance settings and make sure everything is as it should be. Back up your data and try again. good luck

  • How come in Finder, when I search "This Mac", there's fewer results than when searching somewhere more specific? Shouldn't it be the opposite?

    I have my preferences set so that New Finder windows show Macintosh HD. So when I open a Finder window, five folders are shown: Applications, Library, System, User Information, and User. As an example of the subject of my question, I opened a Finder window and typed "hp" in the search field. Four results were displayed: HP ePrint.app, two other apps that open the printing queues of HP printers, and an HTML document of bookmarks with two bookmarks containing "hp" in their names. My goal of the search* was to find a folder named "hp", of which there are two that I know of on my computer. Their locations are: 'Macintosh HD/Library/Printers' and 'Macintosh HD/Library/Application Support'—neither folder was found when searched for in "This Mac" nor when searched for in "Macintosh HD". When I searched for "hp" in the Library folder, 36 results were displayed, including the two folders named "hp". Above those 36 items, it clearly indicated that my search was conducted in the Library folder, and that I was able to click "This Mac" to search my whole computer instead. Clicking "This Mac" resulted in the same four items that were found when I searched for "hp" immediately after opening the Finder window to be displayed again. In my mind, clicking "This Mac" should at least keep the 36 items found in my Library folder to remain displayed. My reason for thinking this is because the Library folder is contained in "This Mac", isn't it? The same logic applies to Macintosh HD also; why doesn't searching there return at least the same 36 results? This phenomenon of the contained location returning more search results than the location which contains it frustrates me. When I search for something, I have to guess if it's in Library or System (if it's in one of the other folders, I'm always certain of which to search). I know that doesn't seem like a big deal, it just doesn't make sense to me why I can't find things by searching in "This Mac" or Macintosh HD. Until I got this MacBook (15" Pro Retina mid 2012, 2.6/16/256) , I was a lifelong Windows user. I love my MacBook, but this search idiosyncrasy is the only thing about it that seems inferior to its Windows counterpart. Searching for something in Windows is easier to me because locations behave hierarchically. I still like my MBP way better than any other computer that I've ever owned before, I just wish Apple would change this one attribute. If anyone knows how to make the Finder search behave completely hierarchically (when the containing location returns at least the same search results as the location it contains), please let me know. Thank you.
    *The "hp" folder search that I conducted was done only as an example of the issue that I discussed here. I knew where the folders were, thus, it was easier for me to explain the problem that was posed in my question.

    Start with http://www.pinkmutant.com/articles/Leopard/leospot.html and http://www.thexlab.com/faqs/stopspotlightindex.html, then my mod to Finder's Find at http://www.macosxhints.com/article.php?story=20080229204517495 for what you can change so you can find stuff excluded by the default structure.

  • I just made the switch to mac. I am have installed all the new PS6 CC and bridge and I am now trying to add some presets to my  ACR but when I search for the folder to place them it is not there.  From what I researched it says it should be under camera l

    I just made the switch to mac. I am have installed all the new PS6 CC and bridge and I am now trying to add some presets to my  ACR but when I search for the folder to place them it is not there.  From what I researched it says it should be under camera library/application support/adobe/camera raw/settings but I can only get to library/application support/adobe/ and then there are two different camera raw options I have checked both and there are not settings folder. If anyone can help me please thanks

    Apple most likely has the same poor taste that Microsoft does when it come to defaults.  Microsoft likes to hide things like  settings, preset, folders etc from normal users  think the dumb or something else.  If Apple also hide things you will have to  make some system setting changes that will allow Finder to do it job and find it for you.

  • My instagram app icon on my iphone 4 is missing. When I go to the app store and try to reinstall it, it says open. When i search for it on my phone it can't find it? What should I do?

    My instagram app icon on my iphone 4 is missing. When I go to the app store and try to reinstall it, it says open. When I search for it on my phone it can't find it? What should I do?

    Make sure your phone is connected to the computer and iTunes is open
    1. Visit Instagram.com from your computer web browser
    2. Click "Download in the app store"
    3. It will download and show up in your iTunes
    4. Highlight and sync the app to your iPhone (note: it will not show up on your phone, even after it says syncing is complete).
    5. In iTunes, select the Instagram icon and click "Remove" or "Uninstall"
    6. Click Accept and Uninstall when it asks you to confirm as it will remove instagram and its data from your iPhone
    7. Disconnect the phone from the computer
    8. Manually reboot the phone after exiting all apps
    9. Upon re-start, you will be able to access the app in the App Store, and install it

  • When i search on the search bar it also creats a search on my g mail

    when i search in search bar i also get the same search on my gmail acct
    == This happened ==
    Every time Firefox opened
    == last week

    Hello.
    Although possibly not related to your problem, I have to remind you that the version of Firefox you are using at the moment has been discontinued and is no longer supported. On top of this, it has known unpatched bugs and security problems. I urge you to update to the latest version of Firefox, for maximum security, stability, performance and usability. You can get it for free, as always, at [http://www.getfirefox.com getfirefox.com].
    As for your issue, hopefully this support article is what you need:
    http://support.mozilla.com/en-US/kb/Searches+are+redirected+to+another+site
    In any case, it's possible that you are having a problem with some Firefox add-on that is hindering your Firefox's normal behavior. Have you tried disabling all add-ons (just to check), to see if Firefox goes back to normal?
    Whenever you have a problem with Firefox, whatever it is, you should make sure it's not caused by one (or more than one) of your installed add-ons, be it an extension, a theme or a plugin. To do that easily and cleanly, run Firefox in [http://support.mozilla.com/en-US/kb/Safe+Mode safe mode] (don't forget to select ''Disable all add-ons'' when you start safe mode). If the problem disappears, you know it's from an add-on. Disable them all in normal mode, and enable them one at a time until you find the source of the problem. See [http://support.mozilla.com/en-US/kb/Troubleshooting+extensions+and+themes this article] for information about troubleshooting extensions and themes and [https://support.mozilla.com/en-US/kb/Troubleshooting+plugins this one] for plugins.
    If you need support for one of your add-ons, you'll have to contact its author.
    If the problem is not disappears when all add-ons are disabled, please tell me, so we can work from there.

  • Make search criteriaItems as requird/selectivlyReq conditionaly in af:query

    Hi,
    Consider the DepartmentVO. It has DeptName, ManagerName, TotalSalary of Employees in the department. I created a view criteria which includes these 3 fields as the view criteria items. I dropped the view criteria as a query panel in the Ui.
    I don't want mark any of these attributes (view criteria items) as required or selectively required.
    In the search page, I don't want to allow the user to search only with TotalSalary. If your wants to search on TotalSalary, I want to make the DeptName as required/selectively required. At the same time, if user wants to search with ManagerName I DONT want the DeptName as required/selectively required.
    In my actual use case, I have 2 transient attributes (TotalAmt, TransactionDate) for which am getting the values from the ViewAccessors. When I search with TotalAmt, it is taking too much time to return the results. To avoid this, I want to make some other field like MerchantName , as required criteria item when user search only with the field TotalAmt.
    Please share your thoughts.
    Thanks.

    Hi,
    you can override the query listener on the af:query component and if your complex condition is not met, show an error message (either you show an FacesMessage message or open a popup dialog) and don't execute the query
    See:
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/85-querycomponent-fieldvalidation-427197.pdf
    and
    "http://www.oracle.com/technetwork/developer-tools/adf/learnmore/85-querycomponent-fieldvalidation-427197.pdf" (page 15) http://www.oracle.com/technetwork/developer-tools/adf/learnmore/85-querycomponent-fieldvalidation-427197.pdf
    The latter document is needed as af:query supports switching view criterias (and thus searches) in which case your field dependencies may change
    Frank

  • How to make search between two dates accept null not obligatory search proplem

    Hi guys when i search record between two dates it works ok success but you must enter date from and dateto first to  to make search
    i will show what i need from this example
    I need to search dynamic by 4 textbox
    1-datefrom
    2-dateto
    3-EmployeeNo
    4-EmployeeName
    but search i need must be dynamic meaning
    if i enter employee no only give me employee no found in database
    if i enter employee name give me employees found with this name using like
    if i enter all 4 text box null and enter button search get all data
    but i have proplem in this query when i need to search by click search button
    i must write date from and date to firstly then write employee no or employee name if i need to search
    so that i need to search by employee no alone or employee name alone without using date from and date to
    And if i search without using datefrom and dateto it give me message error 'string wasnot recognized as valid datetime"
    my stored procedure and code as following :
    ALTER proc [dbo].[CollectsearchData]
    @StartDate datetime,
    @EndDate datetime,
    @EmployeeID  NVARCHAR(50),
    @EmployeeName  nvarchar(50)
    as
    Begin
    Declare @SQLQuery as nvarchar(2000)
    SET @SQLQuery ='SELECT * from ViewEmployeeTest Where (1=1)'
    If (@StartDate is not NULL)
    Set @SQLQuery = @SQLQuery + ' And (joindate >= '''+ Cast(@StartDate as varchar(100))+''')'
    If (@EndDate is not NULL)
    Set @SQLQuery = @SQLQuery + ' And (joindate <= '''+ Cast(@EndDate as varchar(100))+''')' 
    If @EmployeeID <>''
    Set @SQLQuery = @SQLQuery + 'And (EmployeeID = '+ @EmployeeID+') '
    If @EmployeeName Is Not Null
    Set @SQLQuery = @SQLQuery + ' AND (DriverName LIKE
    ''%'+@EmployeeName+'%'') '
    Print @sqlQuery
    Exec (@SQLQuery) 
    End
    Function using
    public DataTable SearchDataA(string ConnectionString,string EmployeeNo,string EmployeeName, DateTime StartDate, DateTime EndDate)
    SqlConnection con = new SqlConnection(ConnectionString);
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = con;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "CollectsearchData";//work
    cmd.Parameters.Add("@StartDate", SqlDbType.DateTime);
    cmd.Parameters.Add("@EndDate", SqlDbType.DateTime);
    cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar, 50);
    cmd.Parameters.Add("@EmployeeName", SqlDbType.NVarChar, 50);
    cmd.Parameters["@StartDate"].Value = StartDate;
    cmd.Parameters["@EndDate"].Value = EndDate;
    cmd.Parameters["@EmployeeID"].Value = EmployeeNo;
    cmd.Parameters["@EmployeeName"].Value = EmployeeName;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    DataSet ds = new DataSet();
    da.Fill(ds);
    DataTable dt = ds.Tables[0];
    return dt;
    interface button search
     try
    CultureInfo ukCulture = new CultureInfo("en-GB");             
    FleetManagment.Fleet fleet = new FleetManagment.Fleet();
    DataTable Table = fleet.SearchDataA("Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "",textBox3.Text,textBox4.Text, DateTime.Parse(textBox1.Text,
    ukCulture.DateTimeFormat), Convert.ToDateTime(textBox2.Text, ukCulture.DateTimeFormat));
    dataGridView1.DataSource = Table;
    dataGridView1.Refresh();
    catch (Exception ex)
    MessageBox.Show(ex + "error");

    Yes, the below code should not be passed any value: (I am not sure of the syntax in .NET,Sorry) 
    --If startdate len is 0 - do not assign this value
    cmd.Parameters["@StartDate"].Value = StartDate;
    --If endate len is 0 - do not assign this value
    cmd.Parameters["@EndDate"].Value = EndDate;

Maybe you are looking for