Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Dim Conn As SqlConnection
Dim Cmd As SqlCommand
Dim dtReader As SqlDataReader
Dim sql As String
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strConnString As String
strConnString = "Data Source=IK-PC\HUSOC;Initial Catalog=db_husoc;Persist Security Info=True;User ID=user_husoc;Password=1842531;"
Conn = New SqlConnection(strConnString)
Conn.Open()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If txtaddress.Text <> "" Then
sql = "update tb_member set mem_address = '" & Me.txtaddress.Text & "' where mem_id = 1"
Cmd = New SqlCommand(sql, Conn)
Dim sta As String = Cmd.ExecuteNonQuery()
If sta Then
Me.lblText.Text = "บันทึกข้อมูลเรียบร้อย"
Me.lblText.ForeColor = Drawing.Color.Green
Else
Me.lblText.Text = "เกิดข้อผิดพลาด"
Me.lblText.ForeColor = Drawing.Color.Red
End If
Else
Me.lblText.Text = "กรุณากรอกข้อมูล"
Me.lblText.ForeColor = Drawing.Color.Red
Me.txtaddress.Focus()
End If
End Sub
End Class