Ver Mensaje Individual
  #3 (permalink)  
Antiguo 24/03/2003, 22:09
Avatar de MsTech.DotNet
MsTech.DotNet
 
Fecha de Ingreso: marzo-2003
Ubicación: Maracay - Edo. Aragua
Mensajes: 605
Antigüedad: 22 años
Puntos: 0
Mensaje Codigo

Aqui esta el codigo... repito... es un copy & paste del mismo codigo que esta en el framework solo que cuando lo ejecuto por el framework si funciona pero cuando lo corro desde una carpeta del IIS que yo cree entonces no me funciona... no da error sino que no termina de cargar cuando le doy por ejemplo a eliminar...

Codigo:

<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Dim MyConnection As SqlConnection

Sub Page_Load(Sender As Object, E As EventArgs)

MyConnection = New SqlConnection("server=(local);database=pubs;Truste d_Connection=yes")

If Not (IsPostBack)
BindGrid()
End If
End Sub

Sub MyDataGrid_Delete(Sender As Object, E As DataGridCommandEventArgs)

Dim MyCommand As SqlCommand
Dim DeleteCmd As String = "DELETE from Employee where emp_id = @Id"

MyCommand = New SqlCommand(DeleteCmd, MyConnection)
MyCommand.Parameters.Add(New SqlParameter("@Id", SqlDbType.NVarChar, 11))
MyCommand.Parameters("@Id").Value = MyDataGrid.DataKeys(CInt(E.Item.ItemIndex))

MyCommand.Connection.Open()

Try
MyCommand.ExecuteNonQuery()
Message.InnerHtml = "<b>Registro eliminado</b><br>" & DeleteCmd
label1.text=DeleteCmd.tostring()
Catch Exc As SQLException
Message.InnerHtml = "ERROR: no se pudo eliminar el registro"
Message.Style("color") = "red"
End Try

MyCommand.Connection.Close()

BindGrid()

End Sub

Sub BindGrid()

Dim DS As DataSet
Dim MyCommand As SqlDataAdapter
MyCommand = New SqlDataAdapter("select * from Employee", MyConnection)

DS = new DataSet()
MyCommand.Fill(DS, "Employee")

MyDataGrid.DataSource=DS.Tables("Employee").Defaul tView
MyDataGrid.DataBind()
End Sub

</script>
<html>
<head>
</head>
<body style="FONT: 10pt verdana">
<form runat="server">
<h3><font face="Verdana">Eliminar la fila de datos</font>
</h3>
<span id="Message" runat="server" enableviewstate="false">
<p>
<asp:Label id="Label1" runat="server"></asp:Label>
</p>
<p>
<ASP:DataGrid id="MyDataGrid" runat="server" OnDeleteCommand="MyDataGrid_Delete" DataKeyField="emp_id" HeaderStyle-BackColor="#aaaadd" Font-Size="8pt" Font-Name="Verdana" CellSpacing="0" CellPadding="3" ShowFooter="false" BorderColor="black" BackColor="#ccccff" Width="800">
<Columns>
<asp:ButtonColumn Text="Delete Employee" CommandName="Delete" />
</Columns>
</ASP:DataGrid>
</p>
</span>
</form>
</body>
</html>

Si me pueden ayudar se los agradeceria... me urge arreglar esto... porque estoy desarrollando un proyecto que tengo que entregar en 3 semanas

Saludos
__________________
Ing. Javier Ugalde
Desarrollador de Aplicaciones Web / Windows
Director de Desarrollos Web
Ing. en Información
Email: [email protected]
Telf. Hab: +[58] - (243) - 232.02.06
Telf. Cel: +[58] - (414) - 455.26.80

Última edición por MsTech.DotNet; 24/03/2003 a las 22:12