jueves, 12 de marzo de 2009

Uso de la Sentencia sql "LIKE" en ASP.net

La mayoría de las operaciones con registros hacia una base de datos (Oracle, SQL Server, MySql, Access, etc) se resumen en practicamente 4 principales:
- Consultar
- Ingresar Registrar
- Modificar
- Eliminar
Que su equivalente en el lenguaje Universal SQL son:
- SELECT
- INSERT
- UPDATE
- DELETE
En esta ocación voy a colocar un ejemplo de una consulta de tipo SELECT utilizando tambien LIKE que devuelve las coincidencias encontradas segun los parámetros dentro del LIKE, este código funciona en ASP.net con C#.net y en cualquier entorno tambien .NET (J#.net, VB.net, COBOL.net, etc):

BaseDatos.Conectar();
GridView1.DataSource = BaseDatos.ConsultaDS("SELECT claveEmpleado, nombre,
apellidoPaterno, apellidoMaterno, sexo, FechaNacimiento, correoElectronico,
telefono, fechaIngreso, status FROM Empleados WHERE apellidoPaterno LIKE ('" +
TextApellidoPaterno.Text + "%')");
GridView1.DataBind();
BaseDatos.Desconectar();

Lo importante es en :

WHERE apellidoPaterno LIKE ('" + TextApellidoPaterno.Text + "%')

Que esta indicando que la consulta SELECT devolverá todas las filas que coincidan al principio con lo que se escriba en el TextBox.
Por ejemplo:
Si en mis registros de la tabla en mi base de datos tengo en el campo "apellidoPaterno" :Peña, Perera, Prieto, Palomeque, y en el textbox para consultar escribo "pe" me devolvera las filas que contienen el nombre Peña y Perera.
Espero y les sirva a algunos, porque esto los master ya lo saben muy bien.

38 comentarios:

Anónimo dijo...

Great blog! Is your theme custom made or did
you download it from somewhere? A design like yours with a few
simple tweeks would really make my blog shine. Please let me know where
you got your theme. Bless you

Here is my web page ... miu miu 財布

Anónimo dijo...

I am truly grateful to the holder of this website who has shared this great paragraph at here.



my web site :: コーチメンズバッグ

Anónimo dijo...

Hi, i think that i noticed you visited my weblog so i got here to return the
prefer?.I am trying to to find issues to enhance my web site!

I assume its adequate to use a few of your ideas!!

Here is my weblog miu miu 新作

Anónimo dijo...

Attractive section of content. I just stumbled upon your blog and in accession capital to assert that I acquire in fact enjoyed account your blog posts.
Anyway I'll be subscribing to your feeds and even I achievement you access consistently rapidly.

Take a look at my web-site; ミュウミュウ

Anónimo dijo...

Pretty nice post. I just stumbled upon your weblog and wanted
to say that I've really enjoyed surfing around your blog posts. After all I will be subscribing to your feed and I hope you write again soon!

Here is my blog - クロエバッグ

Anónimo dijo...

I go to see daily some sites and blogs to read articles or reviews, except this website gives quality based content.


Feel free to surf to my homepage :: トリーバーチ店舗

Anónimo dijo...

This post is invaluable. Where can I find out more?

Here is my weblog :: chloe バッグ

Anónimo dijo...

I visited various web pages but the audio quality for audio
songs current at this web page is in fact excellent.

Visit my web page ... 財布トリーバーチ

Anónimo dijo...

I think the admin of this web site is truly working hard for his website, for the reason that here every
material is quality based data.

Here is my web site :: http://www.toryburchoutletshopx.com/

Anónimo dijo...

Good day! I could have sworn I've visited this blog before but after looking at many of the posts I realized it's new
to me. Anyhow, I'm certainly pleased I found it and I'll
be bookmarking it and checking back regularly!


Also visit my blog ... chloe バッグ

Anónimo dijo...

Appreciation to my father who stated to me concerning
this weblog, this webpage is truly amazing.

my webpage - chloe 財布

Anónimo dijo...

Useful information. Fortunate me I found your website by chance,
and I am surprised why this accident didn't came about in advance! I bookmarked it.

My page :: ミュウミュウバッグ

Anónimo dijo...

whoah this blog is excellent i really like studying your articles.

Keep up the good work! You already know, lots of people
are hunting round for this information, you could
help them greatly.

Check out my web blog chloe バッグ

Anónimo dijo...

Hi there! This article could not be written much better! Looking at this post reminds me of my previous roommate!
He always kept talking about this. I will send this post to him.
Pretty sure he'll have a good read. Thank you for sharing!

Also visit my homepage: http://louboutinshoeonline.webs.com

Anónimo dijo...

Wow, marvelous weblog format! How long have you ever been blogging for?
you made running a blog look easy. The overall glance
of your website is excellent, as smartly as the content material!



Also visit my web site - coach 財布

Anónimo dijo...

Hi there, this weekend is good in favor of me, because this time i am reading this great informative piece of writing here at my home.


Feel free to surf to my homepage; miu miu 財布

Anónimo dijo...

Today, I went to the beachfront with my kids.

I found a sea shell and gave it to my 4 year old
daughter and said "You can hear the ocean if you put this to your ear." She
placed the shell to her ear and screamed. There was a hermit
crab inside and it pinched her ear. She never wants to go
back! LoL I know this is completely off topic but
I had to tell someone!

Feel free to visit my page miu miu 財布

Anónimo dijo...

Hi there, You have done a fantastic job. I will certainly digg
it and personally recommend to my friends. I am
sure they will be benefited from this site.


Here is my website ... クロエ店舗

Anónimo dijo...

Hi mates, its enormous paragraph concerning
educationand completely defined, keep it up all the
time.

Feel free to visit my blog post - chloe バッグ

Anónimo dijo...

Every weekend i used to visit this site, for the reason that
i wish for enjoyment, for the reason that this this web site conations in fact pleasant funny
material too.

Feel free to surf to my blog post: coach バッグ

Anónimo dijo...

It is perfect time to make some plans for the future and it is time
to be happy. I have read this post and if I could I desire to suggest you few interesting things
or advice. Maybe you can write next articles referring to this article.
I want to read more things about it!

My blog - ミュウミュウ長財布

Anónimo dijo...

It is perfect time to make some plans for the future and
it is time to be happy. I have read this post and if I could I desire to suggest you few interesting things or advice.
Maybe you can write next articles referring to
this article. I want to read more things about it!


Also visit my weblog - ミュウミュウ長財布

Anónimo dijo...

Very good article. I certainly appreciate this site.
Stick with it!

Here is my webpage; www.abercrombiefitchclothesoutletsale.com

Anónimo dijo...

Very nice post. I definitely appreciate this site.
Thanks!

Also visit my webpage :: エアジョーダン

Anónimo dijo...

Wow, marvelous weblog layout! How lengthy have you been blogging for?
you made running a blog look easy. The overall glance of your website is fantastic, as well as the
content!

Here is my homepage アバクロンビー

Anónimo dijo...

I leave a response when I especially enjoy a
post on a website or if I have something to add to the discussion.
Usually it's a result of the sincerness communicated in the article I read. And on this article "Uso de la Sentencia sql "LIKE" en ASP.net". I was excited enough to leave a comment :-P I do have a couple of questions for you if it's allright.
Is it just me or does it look like like a few of these responses look like
they are written by brain dead folks? :-P And, if you are posting on other
places, I'd like to keep up with anything new you have to post. Would you make a list every one of your shared pages like your Facebook page, twitter feed, or linkedin profile?

my web blog ルイヴィトン財布

Anónimo dijo...

This post presents clear idea for the new users of blogging, that really how
to do blogging.

Also visit my website: chanel バッグ

Anónimo dijo...

I think the admin of this web site is actually working hard in support of his web site, since here every material
is quality based stuff.

Feel free to visit my web page - オークリー サングラス

Anónimo dijo...

Howdy just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Firefox.
I'm not sure if this is a format issue or something to do with browser compatibility but I thought I'd post to let
you know. The layout look great though! Hope you get the issue resolved soon.
Cheers

Visit my web-site; ロレックスレプリカ

Anónimo dijo...

Do you have a spam problem on this blog; I also am a blogger, and I was curious about
your situation; we have created some nice practices and
we are looking to exchange solutions with others, please shoot me an email
if interested.

Look at my webpage :: グッチ

Anónimo dijo...

Heya superb website! Does running a blog such as this take
a large amount of work? I have virtually no understanding of
coding however I was hoping to start my own blog
in the near future. Anyway, if you have any ideas or tips for new blog owners
please share. I understand this is off subject but
I just had to ask. Many thanks!

Here is my web-site :: エアジョーダン

Anónimo dijo...

I'm not sure where you're getting your information, but good topic.
I needs to spend some time learning more or understanding more.
Thanks for excellent info I was looking for this info for my mission.


My blog post: シャネルバッグ

Anónimo dijo...

I have read so many articles or reviews regarding the blogger lovers except this
paragraph is in fact a fastidious paragraph, keep it up.


Also visit my web site プラダバッグ

Anónimo dijo...

I’m not that much of a online reader to be honest but
your blogs really nice, keep it up! I'll go ahead and bookmark your website to come back in the future. Cheers

Here is my web-site レイバン

Anónimo dijo...

What's up, always i used to check weblog posts here in the early hours in the morning, because i love to find out more and more.

Here is my website :: ロレックスコピー

Anónimo dijo...

I read this post completely on the topic of the resemblance of newest
and previous technologies, it's remarkable article.

Feel free to surf to my webpage; ロレックスレプリカ

Anónimo dijo...

I was curious if you ever thought of changing the structure of your site?
Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better.
Youve got an awful lot of text for only having 1 or two images.
Maybe you could space it out better?

my blog post monster beats

Anónimo dijo...

I do not know whether it's just me or if perhaps everybody else encountering issues with your website. It seems like some of the text within your posts are running off the screen. Can somebody else please comment and let me know if this is happening to them too? This could be a issue with my browser because I've had this happen
previously. Kudos

My web-site; www.airshoeshanbai.com