Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Friday, March 23, 2012

How to make a SELECT with a field name inside a variable?

I have a table (for example PERSONS) with several fields (NIF NAME AGE).
I have a cursors than read the differents fiels tat have this table inside a trigger fron another table that contain all the fields of the tables.
This cursor save the name of the fiels inside the variable @.FIELD.
I need to read the value of the several records of the table like:

@.FIELD='NIF' <--(CURSOR)

SELECT @.FIELS FEOM INSERTED --> select nif from inserted(persons)

This sentence doesn't works. How can I do?

Thanks, Otto Martinez.Hi,
you maye use a variable to generate the whole statement then use the exec command
Declare @.sql NVarchar(200)
set @.sql= "Select " + @.Fiels +" from inserted"
exec @.sql

How to make a search engine to search my database

hi there,

i am doing a school project and i need to have this search engine that will search the data that i have stored inside the database and display the results out

can anyone help?

thanks

When you say "help", do you mean provide assistance with errors that you are encountering on something you have already started, or do you mean "do it for you"? In other words, what have you done so far?

Also, what database are you using? Which language do you use?

|||

If you are using SQL Server or SQLEXPRESS both have FullText Search indexing built in. If there is no native FullText search in some other RDBMS that you are using then try DotLucene.

|||

i am using SQL Server 2005..

i used to study .asp and now i have to change to .aspx and i find tat everything is very different..

i am just starting to do the search engine thing..

and i need some guide... =/

|||

The principals are the same in terms of the SQL. Generally, you will use LIKE and wildcard characters %.

Beyond that, drag a textbox and button onto a form, then a GridView and a SqlDataSource. The GridView needs to be bound to the datasource, which should be set up to connect to your database, and run the SQL that will fetch the search results. Follow some of the Quick Start tutorials or videos to get the hang of working with the new controls.http://www.asp.net/learn/


|||

i manage to make everything and when i test query in the sql server it works..

but when i type in the keyword in the text box and i press submit it dint work.. i have done before the dropdown list where they have this autopostback thing.but for the text how do i code the submit button?

ProtectedSub Button1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Button1.Click

Dim searchAsString = TextBox1.Text

SqlDataSource1.Select("search")

GridView1.DataBind()

|||

try this, worked for me

<asp:AccessDataSourceID="AccessDataSource1"runat="server"DataFile="~/App_Data/brakes.mdb"

SelectCommand="SELECT * FROM [table] WHERE ([field] LIKE '%' + @.field1 + '%')

<SelectParameters>

<asp:ControlParameterControlID="TextBox2"DefaultValue="%"Name="field1"PropertyName="Text"/>

</SelectParameters>

</asp:AccessDataSource>

Sunday, February 19, 2012

how to know logged user (odbc) ?

hi
inside a stored procedure :
how can i know
which user is logged on
the current odbc session ?
thanks
--
atte,
Hernán Castelo
SGA - UTN - FRBA"Hernán Castelo" <bajopalabra@.hotmail.com> wrote in message
news:eON6U6jzEHA.3804@.TK2MSFTNGP10.phx.gbl...
> hi
> inside a stored procedure :
> how can i know
> which user is logged on
> the current odbc session ?
> thanks
> --
> atte,
> Hernán Castelo
> SGA - UTN - FRBA
>
Take a look at the CURRENT_USER function in the Books Online.
Rick Sawtell
MCT, MCSD, MCDBA|||To add to Rick's response, you can also use SUSER_SNAME() to get the login
name.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Hernán Castelo" <bajopalabra@.hotmail.com> wrote in message
news:eON6U6jzEHA.3804@.TK2MSFTNGP10.phx.gbl...
> hi
> inside a stored procedure :
> how can i know
> which user is logged on
> the current odbc session ?
> thanks
> --
> atte,
> Hernán Castelo
> SGA - UTN - FRBA
>|||how i did not guess it ?!
(idiomatic matters...)
thanks
--
atte,
Hernán Castelo
SGA - UTN - FRBA
"Rick Sawtell" <quickening@.msn.com> escribió en el mensaje
news:%23UQodAkzEHA.1564@.TK2MSFTNGP09.phx.gbl...
> "Hernán Castelo" <bajopalabra@.hotmail.com> wrote in message
> news:eON6U6jzEHA.3804@.TK2MSFTNGP10.phx.gbl...
> > hi
> > inside a stored procedure :
> >
> > how can i know
> > which user is logged on
> > the current odbc session ?
> >
> > thanks
> >
> > --
> > atte,
> > Hernán Castelo
> > SGA - UTN - FRBA
> >
> >
>
> Take a look at the CURRENT_USER function in the Books Online.
>
> Rick Sawtell
> MCT, MCSD, MCDBA
>
>