Imports System.Data
Imports System.Data.SqlClient
Public Class index
Inherits System.Web.UI.Page
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Sub btnsave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsave.Click
Dim con As String = "server=TAK\SQLEXPRESS ; uid=sa; pwd=1234; database=web;"
Dim conn As New SqlConnection(con)
conn.Open()
Dim sql As String = "INSERT INTO member (username,password) VALUES (@username,@password)"
Dim cmd As New SqlCommand(sql, conn)
cmd.Parameters.AddWithValue("username", lblusername)
cmd.Parameters.AddWithValue("passowrd", lblpassword)
cmd.ExecuteNonQuery()
conn.Close()
cmd.Parameters.AddWithValue("@username", lblusername.Text) <<< lblusername เป็น control หรือ value
cmd.Parameters.AddWithValue("@passoword", lblpassword.Text) <<< lblpassword เป็น control หรือ value