Imports System
Imports System.data
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
' declare the data set and data adapters
Private ddlArea As New DropDownList
Private daArea As New SqlDataAdapter
Dim cmdselect As SqlCommand
Dim area_reader As SqlDataReader
'declare connection variable to database
Dim oSQLConn As SqlConnection = New SqlConnection
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'on page load connect to databse
user_reg()
' fill_area()
End Sub
Private Sub user_reg()
' connect to the databse
oSQLConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=TaT;" & _
"Integrated Security=SSPI"
oSQLConn.Open()
oSQLConn.Close()
End Sub
Private Sub fill_area()
Dim sqlfillarea As New SqlCommand("SELECT * from tb_area", oSQLConn)
'ddlArea.fill(ddlArea)
oSQLConn.Open()
Me.ddlArea.DataSource = daArea
Me.ddlArea.DataValueField = "area_name"
Me.ddlArea.DataTextField = "area_name"
Me.ddlArea.DataBind()
oSQLConn.Close()
End Sub
Private Sub btn_submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_submit.Click
Dim regtime As New DateTime
'use textboxes as entries
' ,c_user_postcode,c_user_tel_alt,c_user_country, ' now() ','uk'
Dim sqlInsertuser As New SqlCommand("INSERT INTO tb_user(c_user_id,c_user_fname,c_user_sname,c_username_login,c_user_password,c_user_house,c_user_street,c_user_town,c_user_country,c_user_postcode,c_user_email,c_user_tel_alt,c_county,c_date_registered) VALUES('" & txt_mobile.Text & "','" & txt_fname.Text & "','" & txt_sname.Text & "','" & txt_username.Text & "','" & txt_password.Text & "','" & txt_house.Text & "','" & txt_street.Text & "','" & txt_town.Text & "','uk','" & txt_post.Text & "','" & txt_email.Text & "','" & txt_tel.Text & "','" & txt_county.Text & "',getDate());", oSQLConn)
sqlInsertuser.Connection.Open()
sqlInsertuser.ExecuteNonQuery()
oSQLConn.Close()
End Sub