SQLDataReader help
Thanks for any help or suggestions. I am using the SQLDataReader to execute a Stored Procedure that accepts two parameters (BuildingTID and Department) to return the appropritae Value in my case The Director of the Department. My problem is I get the following error when I run the code that I added below for review. Let me also add that the user is selecting the values that I am using for the stored procedure from 2 DropDownLists.
Unable to cast object of type 'System.Boolean' to type 'System.Data.SqlClient.SqlParameter'.
con = New SqlConnection(ConfigurationManager.ConnectionStrin gs("Connect").ConnectionString)
Dim getDirectorsCMD As SqlCommand = New SqlCommand("dbo.spGetDirector", con)
getDirectorsCMD.CommandType = CommandType.StoredProcedure
Dim myParm As SqlParameter = getDirectorsCMD.Parameters.Add("@BuildingTID", SqlDbType.Int, 15).Value = (ddlDepartment.SelectedValue)
Dim myParm1 As SqlParameter = getDirectorsCMD.Parameters.Add("@Department", SqlDbType.VarChar, 50).Value = (ddlDepartment.SelectedItem.Text)
con.Open()
Dim myReader As SqlDataReader = getDirectorsCMD.ExecuteReader()
With txtDirector
.Enabled = True
.Text = myReader("Contact Name")
EndWith
con.Close()
con.Dispose()
|