Return Value ASP.NET newbie

T

Tim::..

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top