Problems with doing an SQL insert stored procedure

Discussion in 'ASP .Net' started by EmJayEm, Jan 11, 2005.

  1. EmJayEm

    EmJayEm Guest

    I'm having some problems with this line when I do a SQL insert stored
    procedure:

    Compiler Error Message: BC30451: Name 'CommandType' is not declared.

    Source Error:


    Line 65: cmd.Parameters.Add( "@EmployeeID", newEmployeeId)
    Line 66:
    Line 67: cmd.CommandType = CommandType.StoredProcedure
    Line 68:
    Line 69: conn.Open()


    Any ideas anyone?

    Thanks,

    EmJ.
    EmJayEm, Jan 11, 2005
    #1
    1. Advertising

  2. Assuming that you imported the System.Data.SqlClient, System.Data.OleDb, or
    another namespace to connect to the DB, did you also import the System.Data
    namespace? I've seen it happen a couple times where the
    System.Data.SqlClient namespace (or whatever is appropriate for the given
    database) is imported since all the connection and command objects, but the
    System.Data namespace is forgotten. You have to import the System.Data
    namespace in order to use the CommandType because it lives in the
    System.Data namespace as System.Data.CommandType.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage

    "EmJayEm" <> wrote in message
    news:Z9WEd.65378$...
    > I'm having some problems with this line when I do a SQL insert stored
    > procedure:
    >
    > Compiler Error Message: BC30451: Name 'CommandType' is not declared.
    >
    > Source Error:
    >
    >
    > Line 65: cmd.Parameters.Add( "@EmployeeID",
    > newEmployeeId)
    > Line 66:
    > Line 67: cmd.CommandType = CommandType.StoredProcedure
    > Line 68:
    > Line 69: conn.Open()
    >
    >
    > Any ideas anyone?
    >
    > Thanks,
    >
    > EmJ.
    >
    Mark Fitzpatrick, Jan 11, 2005
    #2
    1. Advertising

  3. EmJayEm

    Karl Seguin Guest

    Make sure that System.Data is imported...my guess is that you only have
    System.Data.SqlClient or System.data.OleDbClient

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "EmJayEm" <> wrote in message
    news:Z9WEd.65378$...
    > I'm having some problems with this line when I do a SQL insert stored
    > procedure:
    >
    > Compiler Error Message: BC30451: Name 'CommandType' is not declared.
    >
    > Source Error:
    >
    >
    > Line 65: cmd.Parameters.Add( "@EmployeeID",

    newEmployeeId)
    > Line 66:
    > Line 67: cmd.CommandType = CommandType.StoredProcedure
    > Line 68:
    > Line 69: conn.Open()
    >
    >
    > Any ideas anyone?
    >
    > Thanks,
    >
    > EmJ.
    >
    >
    Karl Seguin, Jan 11, 2005
    #3
  4. EmJayEm

    Curt_C [MVP] Guest

    Hmm... should work. Try using the full namespace.
    How is cmd declared?

    --
    Curt Christianson
    Site & Scripts: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "EmJayEm" <> wrote in message
    news:Z9WEd.65378$...
    > I'm having some problems with this line when I do a SQL insert stored
    > procedure:
    >
    > Compiler Error Message: BC30451: Name 'CommandType' is not declared.
    >
    > Source Error:
    >
    >
    > Line 65: cmd.Parameters.Add( "@EmployeeID",
    > newEmployeeId)
    > Line 66:
    > Line 67: cmd.CommandType = CommandType.StoredProcedure
    > Line 68:
    > Line 69: conn.Open()
    >
    >
    > Any ideas anyone?
    >
    > Thanks,
    >
    > EmJ.
    >
    Curt_C [MVP], Jan 11, 2005
    #4
  5. EmJayEm

    EmJayEm Guest

    Cheers guys for replying.

    I didn't have the System.Data namespace


    EmJ.


    "Mark Fitzpatrick" <> wrote in message
    news:uteAZmB%...
    > Assuming that you imported the System.Data.SqlClient, System.Data.OleDb,
    > or another namespace to connect to the DB, did you also import the
    > System.Data namespace? I've seen it happen a couple times where the
    > System.Data.SqlClient namespace (or whatever is appropriate for the given
    > database) is imported since all the connection and command objects, but
    > the System.Data namespace is forgotten. You have to import the System.Data
    > namespace in order to use the CommandType because it lives in the
    > System.Data namespace as System.Data.CommandType.
    >
    > Hope this helps,
    > Mark Fitzpatrick
    > Microsoft MVP - FrontPage
    >
    > "EmJayEm" <> wrote in message
    > news:Z9WEd.65378$...
    >> I'm having some problems with this line when I do a SQL insert stored
    >> procedure:
    >>
    >> Compiler Error Message: BC30451: Name 'CommandType' is not declared.
    >>
    >> Source Error:
    >>
    >>
    >> Line 65: cmd.Parameters.Add( "@EmployeeID",
    >> newEmployeeId)
    >> Line 66:
    >> Line 67: cmd.CommandType = CommandType.StoredProcedure
    >> Line 68:
    >> Line 69: conn.Open()
    >>
    >>
    >> Any ideas anyone?
    >>
    >> Thanks,
    >>
    >> EmJ.
    >>

    >
    >
    EmJayEm, Jan 11, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nicholas

    insert stored procedure

    nicholas, Nov 17, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    502
    nicholas
    Nov 17, 2004
  2. Mike P
    Replies:
    0
    Views:
    3,275
    Mike P
    Jun 19, 2006
  3. Quinet, Joel
    Replies:
    0
    Views:
    479
    Quinet, Joel
    Aug 8, 2003
  4. Replies:
    3
    Views:
    13,924
    raghav
    Sep 6, 2006
  5. Bill Kellaway

    ASP / Stored Procedure SQL Insert Help

    Bill Kellaway, Oct 10, 2003, in forum: ASP General
    Replies:
    7
    Views:
    203
    Bill Kellaway
    Oct 12, 2003
Loading...

Share This Page