...

View Full Version : .aspx.vb file



cgibie
05-14-2007, 04:32 AM
Is there a way that I can put this into the file with extension .aspx.vb instead of the extension .aspx?



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:



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

Nischumacher
05-14-2007, 09:56 AM
JuST PaSTe THe CoDe iN THe VB CoDe BeHiND FiLE... aND aDD a HaNDLeR To THe CliCK eVeNT... Handles btnSubmit.Click...

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...

Imports System.Data.SqlClient



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum