Asp y bd

Solo disponible en BuenasTareas
  • Páginas : 6 (1285 palabras )
  • Descarga(s) : 0
  • Publicado : 16 de junio de 2011
Leer documento completo
Vista previa del texto
Codigos Asp ocupados en creacionde pagina web del proyecto

Para Bicicleta se ocupo el siguiente codigo:

Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class Bicicletas
Inherits System.Web.UI.Page
Dim strcon As String = "Data Source=ALFCL-PC;Initial Catalog=DigiCleta;Integrated Security=True"
Dim cn As SqlConnection
Dim cm As SqlCommandDim dreader As SqlDataReader
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
cn = New SqlConnection(strcon)
cn.Open()
cm = New SqlCommand("insert into Bicicleta values ('" & TextBox4.Text & "', '" & TextBox1.Text & "', '" & TextBox2.Text & "','" &TextBox3.Text & "')", cn)
If cm.ExecuteNonQuery Then
Response.Write("Registro entro")
Else
Response.Write(" no Entro")
End If
Dim adap As New SqlDataAdapter("select * from Bicicleta", cn)
Dim ds As New DataSet

adap.Fill(ds, "MisDatos")
GridView1.DataSource = dsGridView1.DataMember = "Misdatos"
GridView1.DataBind()
cm.Dispose()

cn.Close()

cn.Dispose()
Catch ex As Exception
Response.Write("Problemas en la base de datos")
End Try
End Su
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
cn = NewSqlConnection(strcon)
cn.Open()
cm = New SqlCommand("update Bicicleta set Rut = '" & TextBox1.Text & "' , Marca = '" & TextBox2.Text & "', Color = '" & TextBox3.Text & "' Where NumBicicleta ='" & TextBox4.Text & "'", cn)
If cm.ExecuteNonQuery Then
Response.Write("Registro Modificado")
Else
Response.Write(" noEncontrado")
End If
Dim adap As New SqlDataAdapter("select * from Bicicleta", cn)
Dim ds As New DataSet

adap.Fill(ds, "MisDatos")
GridView1.DataSource = ds
GridView1.DataMember = "Misdatos"
GridView1.DataBind()

End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Clickcn = New SqlConnection(strcon)
cn.Open()
cm = New SqlCommand(" Delete from Bicicleta Where NumBicicleta ='" & TextBox4.Text & "'", cn)
If cm.ExecuteNonQuery Then
Response.Write("Registro Borrado")
Else
Response.Write(" no Borrado")
End If
Dim adap As New SqlDataAdapter("select * from Bicicleta", cn)Dim ds As New DataSet

adap.Fill(ds, "MisDatos")
GridView1.DataSource = ds
GridView1.DataMember = "Misdatos"
GridView1.DataBind()

End Sub End Class
Para ingreso se ocupo el siguiente codigo:

Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class ingreso
Inherits System.Web.UI.Page
Dim strcon As String = "DataSource=ALFCL-PC;Initial Catalog=DigiCleta;Integrated Security=True"
Dim cn As SqlConnection
Dim cm As SqlCommand
Dim dreader As SqlDataReader
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
cn = New SqlConnection(strcon)
cn.Open()
cm = New SqlCommand("insert into Registrosvalues ('" & TextBox1.Text & "', '" & TextBox3.Text & "','" & TextBox4.Text & "')", cn)
If cm.ExecuteNonQuery Then
Response.Write("Registro entro")
Else
Response.Write(" no Entro")
End If
Dim adap As New SqlDataAdapter("select * from Registros", cn)
Dim ds As New DataSet...
tracking img