sp_CustomersDatos

19/01/2006 - 16:57 por james | Informe spam
Hola muy buen día a todos:

Estaba viendo un ejemplo de un cd Tech de Microsoft ASP.Net C#.

el asunto es que desde ListBox tengo una lista y se visualiza en TexBox,
pero solo se queda en un registro y no avanza.

CREATE PROCEDURE sp_CustomersDatos
@codigo varchar
AS
Select CustomerID, CompanyName, ContactName, ContactTitle, Address FROM
Customers
GO

Quizas desde AQUI se puede mover o es un codigo en asp que tengo que
insertar==???

Gracias...

Preguntas similare

Leer las respuestas

#1 Carlos Sacristán
19/01/2006 - 17:12 | Informe spam
Si la tabla Customers tiene más de un registro, ese procedimiento
almacenado te devolvería todos. El problema está en el código, revísalo para
ver si efectivamente vas recogiendo cada nuevo valor


Un saludo

-
"Sólo sé que no sé nada. " (Sócrates)

"james" escribió en el mensaje
news:
Hola muy buen día a todos:

Estaba viendo un ejemplo de un cd Tech de Microsoft ASP.Net C#.

el asunto es que desde ListBox tengo una lista y se visualiza en TexBox,
pero solo se queda en un registro y no avanza.

CREATE PROCEDURE sp_CustomersDatos
@codigo varchar
AS
Select CustomerID, CompanyName, ContactName, ContactTitle, Address FROM
Customers
GO

Quizas desde AQUI se puede mover o es un codigo en asp que tengo que
insertar==???

Gracias...
Respuesta Responder a este mensaje
#2 james
19/01/2006 - 18:50 | Informe spam
No se si me puedas ayudar este es mi codigo

string conexion = "Provider = SQLOLEDB; data source= JAMES-640F43CDE;
initial catalog=Northwind; user id=sa";
private void Page_Load(object sender, System.EventArgs e)
{
if (! Page.IsPostBack)
CreaClientes();

}
private void CreaClientes()
{
OleDbConnection conn = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
OleDbDataReader dr;
string cmdText = "sp_CustomersList";
try
{
conn = new OleDbConnection(conexion);
conn.Open();
cmd = new OleDbCommand(cmdText, conn);
cmd.CommandType = CommandType.StoredProcedure;
dr = cmd.ExecuteReader();
lstClientes.DataTextField="CompanyName";
lstClientes.DataValueField="CustomerID";
lstClientes.DataSource = dr;
lstClientes.DataBind();
dr.Close();
}
finally
{
conn.Close();
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lstClientes.SelectedIndexChanged += new
System.EventHandler(this.lstClientes_SelectedIndexChanged);
this.btnNuevo.Click += new System.EventHandler(this.btnNuevo_Click);
this.btnInsertar.Click += new System.EventHandler(this.btnInsertar_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void lstClientes_SelectedIndexChanged(object sender,
System.EventArgs e)
{
OleDbConnection conn= new OleDbConnection();
OleDbCommand cmd= new OleDbCommand();
OleDbDataReader dr;
string cmdText = "sp_CustomersDatos";
try
{
conn= new OleDbConnection (conexion);
conn.Open();
cmd = new OleDbCommand(cmdText, conn);
cmd.CommandType = CommandType.StoredProcedure;
OleDbParameter pCodigo = new OleDbParameter("@codigo", OleDbType.VarChar);
pCodigo.Value = lstClientes.SelectedItem.Value;
cmd.Parameters.Add(pCodigo);
dr = cmd.ExecuteReader();
if (dr.Read())
{
txtCodigo.Text = dr["CustomerID"].ToString();
txtEmpresa.Text = dr["CompanyName"].ToString();
txtContacto.Text = dr["ContactName"].ToString();
txtCargo.Text = dr["ContactTitle"].ToString();
txtDireccion.Text = dr["Address"].ToString();
}
dr.Close();
}
finally
{
conn.Close();
}
}
Respuesta Responder a este mensaje
#3 Carlos Sacristán
20/01/2006 - 08:40 | Informe spam
Si me preguntas si ese código es correcto la verdad es que no te puedo
contestar, yo trabajo con java. En el foro de programación te contestarán
mejor...


Un saludo

-
"Sólo sé que no sé nada. " (Sócrates)

"james" escribió en el mensaje
news:
No se si me puedas ayudar este es mi codigo

string conexion = "Provider = SQLOLEDB; data source= JAMES-640F43CDE;
initial catalog=Northwind; user id=sa";
private void Page_Load(object sender, System.EventArgs e)
{
if (! Page.IsPostBack)
CreaClientes();

}
private void CreaClientes()
{
OleDbConnection conn = new OleDbConnection();
OleDbCommand cmd = new OleDbCommand();
OleDbDataReader dr;
string cmdText = "sp_CustomersList";
try
{
conn = new OleDbConnection(conexion);
conn.Open();
cmd = new OleDbCommand(cmdText, conn);
cmd.CommandType = CommandType.StoredProcedure;
dr = cmd.ExecuteReader();
lstClientes.DataTextField="CompanyName";
lstClientes.DataValueField="CustomerID";
lstClientes.DataSource = dr;
lstClientes.DataBind();
dr.Close();
}
finally
{
conn.Close();
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lstClientes.SelectedIndexChanged += new
System.EventHandler(this.lstClientes_SelectedIndexChanged);
this.btnNuevo.Click += new System.EventHandler(this.btnNuevo_Click);
this.btnInsertar.Click += new System.EventHandler(this.btnInsertar_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void lstClientes_SelectedIndexChanged(object sender,
System.EventArgs e)
{
OleDbConnection conn= new OleDbConnection();
OleDbCommand cmd= new OleDbCommand();
OleDbDataReader dr;
string cmdText = "sp_CustomersDatos";
try
{
conn= new OleDbConnection (conexion);
conn.Open();
cmd = new OleDbCommand(cmdText, conn);
cmd.CommandType = CommandType.StoredProcedure;
OleDbParameter pCodigo = new OleDbParameter("@codigo", OleDbType.VarChar);
pCodigo.Value = lstClientes.SelectedItem.Value;
cmd.Parameters.Add(pCodigo);
dr = cmd.ExecuteReader();
if (dr.Read())
{
txtCodigo.Text = dr["CustomerID"].ToString();
txtEmpresa.Text = dr["CompanyName"].ToString();
txtContacto.Text = dr["ContactName"].ToString();
txtCargo.Text = dr["ContactTitle"].ToString();
txtDireccion.Text = dr["Address"].ToString();
}
dr.Close();
}
finally
{
conn.Close();
}
}
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida