Can someone please tell me if this is the correct way toreturn a database
value given another value??
E.G:

Select pageID, OfficeName From tblOffice Where PageID = @OfficeName

I would be grateful for any input!

Thanks!


... CODE

Sub GetOfficeID_for_Insert(ByVal e As DataGridCommandEventArgs)

Dim office As String
Dim txtOffice As TextBox

txtOffice = e.Item.FindControl("DDLaddOffice")
office = txtOffice.Text

'Create the appropriate SQL statement
Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim cmd As New SqlCommand("SelectOfficeID", Myconn)
cmd.CommandType = CommandType.StoredProcedure

Myconn.Open()

Dim objOffName As SqlParameter
objOffName = cmd.Parameters.Add("@offName", SqlDbType.NVarChar)
objOffName.Direction = ParameterDirection.Input
objOffName.Value = office

Dim myReader As SqlDataReader = cmd.ExecuteReader()
myReader.Read()

myReader.Close()

Myconn.Close()
End Sub