Sub ViewData()
'*** DataTable ***'
Dim dtAdapter As SqlDataAdapter
Dim dt As New DataTable
strSQL = "SELECT customer.*, center.* FROM customer INNER JOIN center ON customer.center_id = center.center_id WHERE customer.CustomerID = '" & Request.QueryString("CustomerID") & "'"
dtAdapter = New SqlDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
If dt.Rows.Count > 0 Then
Me.txtCustomerID.Text = dt.Rows(0)("CustomerID")
Me.txtName.Text = dt.Rows(0)("Name")
Me.txtEmail.Text = dt.Rows(0)("Email")
Me.txtCountryCode.Text = dt.Rows(0)("CountryCode")
Me.txtBudget.Text = dt.Rows(0)("Budget")
Me.txtUsed.Text = dt.Rows(0)("Used")
Me.txtcenter_name_th.Text = dt.Rows(0)("center_name_th")
End If
End Sub
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim strSQL1 As String
strSQL1 = "UPDATE center SET " & _
" center_name_th = '" & Me.txtcenter_name_th.Text & "' " & _
" WHERE center_id = '" & Request.QueryString("center_id") & "' "
objCmd = New SqlCommand
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandText = strSQL1
.CommandType = CommandType.Text
End With
Me.pnlAdd.Visible = False
Try
objCmd.ExecuteNonQuery()
Me.lblStatus.Text = "Record Updated"
Me.lblStatus.Visible = True
Catch ex As Exception
Me.lblStatus.Text = "Record can not update"
End Try
Response.Redirect("test.aspx")
End Sub
Tag : .NET, Ms SQL Server 2005, Web (ASP.NET), VS 2008 (.NET 3.x)