Wrox Programmer Forums
|
ASP.NET Espanol Esta es una lista de correo dedicada al intercambio de conocimiento sobre ASP.NET en el idioma español.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET Espanol section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 15th, 2003, 05:16 PM
Registered User
 
Join Date: Dec 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to francofm76
Default SELECT de user

Hola grupo
Estoy medio confundido con asp.net, estoy tratando de hacer un select * from xx where xx = 'xx' y no me sale, en asp 3 funciona bien, pero no veo como se hace en asp.net. Yo lo puse de varias maneras y no me funciona:

Dim SelectCommand As String = "SELECT * from agendanet where userid =
'userid' "
o
Dim SelectCommand As String = "SELECT * from agendanet where userid = '" & userid &"' "
o
Dim SelectCommand As String = "SELECT * from agendanet where userid = '" & User.Identity.Name &"' "
o
Dim SelectCommand As String = "SELECT * from agendanet where userid = ' User.Identity.Name ' "

Mi idea es hacer un select y que me traiga datos de una tabla llamada
agendanet y que solo traiga los resultados del usuario logueado, en donde userid es el id de una segunda tabla llamada users.
Dentro de la pagina donde quiero traer los datos, tiene un datagrid, y tengo esta funcion que me trae el usuario PC/Administrator:

    Sub Page_Load(Sender As Object, E As EventArgs)

    Welcome.Text = "Hola, " + User.Identity.Name

             If Not Page.IsPostBack Then

                 BindGrid()

             End If

    End Sub


Que me falta, o que tengo que hacer?
Gracias
 
Old December 16th, 2003, 09:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try:
'un strConn aqui
strSelect = "SELECT userid from agendanet where userid =@myuserid"
cmdSelect = new sqlcommand(strSelect, strConn)

cmdSelect.Parameters.Add("@myuserid", txtUserId.Text)

strConn.Open()
lblAnswer.Text = cmdSelect.ExecuteScalar()
strConn.Close()
 
Old July 17th, 2006, 06:02 PM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by stu9820
 Try:
'un strConn aqui
strSelect = "SELECT userid from agendanet where userid =@myuserid"
cmdSelect = new sqlcommand(strSelect, strConn)

cmdSelect.Parameters.Add("@myuserid", txtUserId.Text)

strConn.Open()
lblAnswer.Text = cmdSelect.ExecuteScalar()
strConn.Close()


Tenía el mismo problema y este código me funcionó perfecto.
Bueno, casi...

Estoy trabajando con VS 2005, así que

Code:
cmdSelect.Parameters.Add("@myuserid", txtUserId.Text)
se encuentra obsoleta.

La solución? Usar:

Code:
cmdSelect.Parameters.AddWithValue("@myuserid", txtUserId.Text)
Simple, no?

Gracias :)








Similar Threads
Thread Thread Starter Forum Replies Last Post
change the text color of (<xsl:value-of select="De ismailc XSLT 2 August 25th, 2008 07:25 AM
Conectar textbox a campo de base de datos Access aya_hbkenshin04 ASP.NET Espanol 0 May 4th, 2006 01:26 PM
Pasar valor de un User Control a una forma aspx emartinez ASP.NET Espanol 2 August 2nd, 2005 02:32 PM
why de sql compiler do not parse de following? deniscuba SQL Language 2 February 4th, 2005 04:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.