Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: .aspx.vb file

  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    279
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .aspx.vb file

    Is there a way that I can put this into the file with extension .aspx.vb instead of the extension .aspx?

    Code:
    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
           
        Dim cnn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("LocalSQLServer").ConnectionString)
            
            Dim cmd = "INSERT INTO users (UserID, Username, Password) VALUES (3, '" & txtUsername.Text & "', '" & txtPassword.Text & "')"
            Dim cnnCommand As New SqlCommand(cmd, cnn)
            Dim insert As Integer
        
            Try
                cnn.Open()
                insert = cnnCommand.ExecuteNonQuery()
                Response.Write("Inserted!")
        
                cnn.Close()
        
            Catch ex As Exception
                Response.Write(ex.ToString())
                
    
            End Try
            
        End Sub
    The above codes also needs thsi header:

    Code:
    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.Data.SqlClient" %>

  • #2
    Regular Coder Nischumacher's Avatar
    Join Date
    Oct 2005
    Location
    Bombay, India
    Posts
    196
    Thanks
    0
    Thanked 2 Times in 2 Posts
    JuST PaSTe THe CoDe iN THe VB CoDe BeHiND FiLE... aND aDD a HaNDLeR To THe CliCK eVeNT... Handles btnSubmit.Click...
    Code:
    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    oR You CaN DouBLe CliCK THe SuBMiT BuTToN... aND THeN aDD THe CoDe WiTHiN THe SuB TaGs...
    aND iMPoRT THe NaMeSPaCe aT THe ToP oF THe PaGe...
    Code:
    Imports System.Data.SqlClient
    - NS 666
    .net DEVILoper


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •