Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'------conect
Dim cn As New SqlConnection(strconn)
With cn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = cn.ConnectionString
cn.Open()
End With
Dim sql As String = ""
Select Case FlagAction
Case "Add"
sql = "insert into PET,TYPE,(Pet_ID,Name_PET,Type_Name,Bind,Sex)"
sql = sql & "values(@Pet_ID,@Name_Pet,@Type_Name,@Bind,@Sex)"
Case "Edit"
sql = (" update PET")
sql &= (" set Name_PET=@Name_PET,")
sql &= (" Type_Name=@Type_Name,")
sql &= (" Bind=@Bind,")
sql &= (" Sex=@Sex")
sql &= (" where (Pet_ID=@Pet_ID)")
End Select
Dim cm As New SqlCommand
With cm
.CommandType = CommandType.Text
.CommandText = sql
.Connection = cn