Link to home
Start Free TrialLog in
Avatar of imstac73

asked on

BC30451: Name 'CommandType' is not declared.

I am getting the following error when I compile my website in VB:
 BC30451: Name 'CommandType' is not declared.

The code that I am using is the same I am using in another page with no issues. Not sure why I am having an issue with the code on a different page. I am using Visual Studio 2008

Code as follows:
Protected Sub btnsavechanges_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSaveChanges.Click
        ' Looping through all the rows in the GridView

        For Each row As GridViewRow In gvForecastSelection.Rows

            Dim oConn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("TestMarketing_ResumesConnectionString").ConnectionString)
            Dim sql As New System.Data.SqlClient.SqlCommand("spForecastProjectsMultipleUpdate")
            sql.Connection = oConn
            sql.CommandType = CommandType.StoredProcedure

            Dim forecastkey As Integer = CType(gvForecastSelection.DataKeys(row.RowIndex).Values("ForecastKeyID"), Integer)
            Dim include As CheckBox = CType(row.FindControl("Include"), CheckBox)

            ' Add parameters to stored procedure

            sql.Parameters.Add(New SqlClient.SqlParameter("@forecastid", Data.SqlDbType.Int))
            sql.Parameters("@forecastid").Value = forecastkey

            sql.Parameters.Add(New SqlClient.SqlParameter("@include", Data.SqlDbType.Float))
            sql.Parameters("@include").Value = include.Checked



        Next row
    End Sub
Avatar of Craig Wagner
Craig Wagner
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of imstac73


Hmmm.that worked.  What's weird is that my other page that uses the same code does not have any Imports listed in it.  

Thanks Craig
That's not possible - you have to import System.Data to use CommandType
Are both pages in the same project? IIRC VB.NET projects allow you to set global Imports so if one project has System.Data set globally and the other didn't that would explain it.