Protected Sub bntSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bntSave.Click
Dim stringUPDATE As String
stringUPDATE = "UPDATE prdtype_db SET name_type=@name_type,isactive=@isactive"
stringUPDATE += " WHERE idtype=" + idtype 'idtype มีจริงครับ
Try
objConn = New SqlConnection(StrConnectstring)
objConn.Open()
Dim objCmd = New SqlCommand(stringUPDATE, objConn)
With objCmd
.Parameters.Add("@name_type", SqlDbType.VarChar).Value = name_prd.Text.Trim
If isactive.Checked = True Then
.Parameters.Add("@isactive", SqlDbType.Char).Value = "y"
Else
.Parameters.Add("@isactive", SqlDbType.Char).Value = "n"
End If
End With
objCmd.ExecuteNonQuery()
Response.Write("บันทึกข้อมูลเรียบร้อยแล้ว")
Catch ex As Exception
Response.Write(ex.Message)
End Try
objConn.Close()
Tag : .NET, Ms SQL Server 2005, VBScript, VB.NET, VS 2010 (.NET 4.x)