how to search a database with a stored procedure?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default how to search a database with a stored procedure?

    hello,

    can any one tell me how to create a stored procedure that is beable to
    search a table, or more table's and can make use of wildcards?
    i just made somthing like this,:
    SELECT * FROM tblUsers WHERE Adress LIKE '* Value from user how wants to
    search the database *'
    but I don't know where to place the @??? for the input
    i also wants to make the user can select witch table and field he want's to
    search.

    thanks!!


    wilco Guest

  2. Similar Questions and Discussions

    1. Stored Procedure
      EXEC master..xp_cmdshell 'cscript c:\path\file.vbs' EXEC master..xp_cmdshell 'c:\path\file.exe' "Kannan" <gk_i@yahoo.com> wrote in message...
    2. stored procedure help
      Hi all! I am in need of writing a few stored procedures. The first one is to create a stored procedure to recover a database from backup and the...
    3. stored procedure value
      How can I bind a stored procedure value to a page? I've executed a stored procedure and there should be two column values created...i.e. col1 and...
    4. NULL in search stored procedure, VB.NET
      Hi I am using a stored procedure to search a single table with "COALESCE(@param,param)" but the NULL default value is being ignored. I think...
    5. Stored procedure from stored procedure
      Is it possible to create a stored procedure from a stored procedure? When I attempt this inanity, it doesn't blow up until syntax error at the...
  3. #2

    Default Re: how to search a database with a stored procedure?

    And when you do it like this someone will sumbit "%' GO DELETE tblUsers --"
    in your input box and wipe out your table (if the database user has enough
    privileges to do so).

    A better solution is to use the command object, like this:

    OleDbCommand cmd = new OleDbCommand();

    cmd.CommandText = "SELECT * FROM [tblUsers] WHERE [Address] LIKE @address";
    cmd.Parameters.Add("@address", "%" + txtAddress.Text + "%");

    Jerry

    "David Wier" <dwier@nospamASPNet101.com> wrote in message
    news:%239pMFNrWDHA.1680@tk2msftngp13.phx.gbl...
    > Dim sAddress as String
    > sAddress=txtAddress.text
    > SQL = "SELECT * FROM tblUsers WHERE Adress Like '%" & sAddress & "%'"
    >
    > Put the % sign on the front and at the end, in order to search the entire
    > field
    >
    > Check out this 2 Part Tutorial on Parameterized Queries:
    > [url]http://aspnet101.com/aspnet101/tutorials.aspx?id=1[/url]
    >
    > LIKE is covered in Part 2
    >
    > David Wier
    > [url]http://aspnet101.com[/url]
    > [url]http://aspexpress.com[/url]
    >
    >
    > "wilco" <wilco.bikker@hetnet.nl> wrote in message
    > news:bgm62m$oou$1@reader11.wxs.nl...
    > > hello,
    > >
    > > can any one tell me how to create a stored procedure that is beable to
    > > search a table, or more table's and can make use of wildcards?
    > > i just made somthing like this,:
    > > SELECT * FROM tblUsers WHERE Adress LIKE '* Value from user how wants to
    > > search the database *'
    > > but I don't know where to place the @??? for the input
    > > i also wants to make the user can select witch table and field he want's
    > to
    > > search.
    > >
    > > thanks!!
    > >
    > >
    >
    >

    Jerry III Guest

  4. #3

    Default Re: how to search a database with a stored procedure?

    Can I ask what is the difference?

    I just want to understand it....

    "Jerry III" <jerryiii@hotmail.com> wrote in message
    news:%23Z1C%23ssWDHA.1480@tk2msftngp13.phx.gbl...
    > And when you do it like this someone will sumbit "%' GO DELETE
    tblUsers --"
    > in your input box and wipe out your table (if the database user has enough
    > privileges to do so).
    >
    > A better solution is to use the command object, like this:
    >
    > OleDbCommand cmd = new OleDbCommand();
    >
    > cmd.CommandText = "SELECT * FROM [tblUsers] WHERE [Address] LIKE
    @address";
    > cmd.Parameters.Add("@address", "%" + txtAddress.Text + "%");
    >
    > Jerry
    >
    > "David Wier" <dwier@nospamASPNet101.com> wrote in message
    > news:%239pMFNrWDHA.1680@tk2msftngp13.phx.gbl...
    > > Dim sAddress as String
    > > sAddress=txtAddress.text
    > > SQL = "SELECT * FROM tblUsers WHERE Adress Like '%" & sAddress & "%'"
    > >
    > > Put the % sign on the front and at the end, in order to search the
    entire
    > > field
    > >
    > > Check out this 2 Part Tutorial on Parameterized Queries:
    > > [url]http://aspnet101.com/aspnet101/tutorials.aspx?id=1[/url]
    > >
    > > LIKE is covered in Part 2
    > >
    > > David Wier
    > > [url]http://aspnet101.com[/url]
    > > [url]http://aspexpress.com[/url]
    > >
    > >
    > > "wilco" <wilco.bikker@hetnet.nl> wrote in message
    > > news:bgm62m$oou$1@reader11.wxs.nl...
    > > > hello,
    > > >
    > > > can any one tell me how to create a stored procedure that is beable to
    > > > search a table, or more table's and can make use of wildcards?
    > > > i just made somthing like this,:
    > > > SELECT * FROM tblUsers WHERE Adress LIKE '* Value from user how wants
    to
    > > > search the database *'
    > > > but I don't know where to place the @??? for the input
    > > > i also wants to make the user can select witch table and field he
    want's
    > > to
    > > > search.
    > > >
    > > > thanks!!
    > > >
    > > >
    > >
    > >
    >
    >

    Xavier MT Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139