27-04-16, 05:39 PM
كود :
If txtname.Text.Trim = String.Empty Then
MsgBox("يرجى ادخال الاسم لغرض البحث")
Exit Sub
End If
Try
Dim cmd As New SqlCommand("Select [id_name] From [tb] Where [name] = @name", conn)
cmd.Parameters.AddWithValue("@name", txtname.Text.Trim)
conn.Open()
txtid.Text = cmd.ExecuteScalar()
conn.Close()
Catch ex As Exception
If conn.State = ConnectionState.Open Then conn.Close()
MsgBox(ex.Message)
End Try